MouseDOWN for two seconds


I need to simulate an ON/OFF switch (which actives after been pressed down for over two seconds). So while the mouse button is pressed DOWN on a button graphic for two seconds the Main Timeline then starts to play again after the two second period so I can continue showing the sequence?

Many thanks,


You can add the following script to the slide On Load event to do that:

var button = prez.object('Your button name');
$(button.node).mousedown(function() {
    button.myMouseDownTimeout = setTimeout(function() {
        delete button.myMouseDownTimeout;
        // continue timeline
    }, 2000);  // wait for 2s (2000ms)
$(document).mouseup(function() {
    if (button.myMouseDownTimeout) {
        delete button.myMouseDownTimeout;


Thank you so much. This works perfect. I have been trying for ages to get this to work!
I didn’t know your software supports these commands - $(button.node).mousedown. This doesn’t appear to be in your manual. Is that correct or have i missed them?

Again, thank you so much :slight_smile:


button.node is the DOM element associated with the button, you can use JavaScript to bind events to it or change its styles… It’s not officially supported so we don’t document it.

$(button.node).mousedown is the way to bind mousedown event to button.node using jQuery library.


Thank you for explaining it.

Hello Again!

You recently helped me with the above issue - regards having JavaScript activate during a ‘mousedown’ press. I have been informed this does not work on an iPad. Is this true?

Many thanks in advance,

Hi Ian,

You can use pointerdown/pointerup events instead of mousedown/mouseup events to make it work on almost all modern browsers on computers or mobile devices.

// replace $(button.node).mousedown(function() { by
$(button.node).on('pointerdown', function() {

// replace $(document).mouseup(function() { by
$(document).on('pointerup', function() {