javascript - How to detect more then 2 second the touchscreen was pressed? -


using google chrome , canary.

how detect more 2 second touchscreen pressed? (with mouse works real-touch screen failing, tested on surface pro 3)

$(document).ready(function() {    var clickstart;   var clickstop;    $(document).bind('contextmenu', function()  {     console.log('touch screen, has no right click.');     return false;   });    $(document).mousedown( function() {     return false;    });    // usb mouse pointer works, real-touch screen not working   $('#vip_anytime').on('mousedown', function(e) {           clickstart = e.timestamp;   }).on('mouseup', function(e) {       clickstop = e.timestamp- clickstart;       if(clickstop >= 2000) {         console.log('>>> after 2 second of hold');       } else {          console.log('>>> before 2 second of hold');       }   });  }); 

try touchstart , touchend events.

    $('#vip_anytime').on('touchstart', function(e) {             clickstart = e.timestamp;     }).on('touchend', function(e) {         clickstop = e.timestamp- clickstart;         if(clickstop >= 2000) {           console.log('>>> after 2 second of hold');         } else {            console.log('>>> before 2 second of hold');         }     }); 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -