javascript - Is there a way to explicitly test if a device supports double-click? -


i wrote game, , allows users configure own game settings.

one of options play card double-clicking it. however, on mobile device, if user selects option, game gets stuck because there no double-click on mobile device.

so i'd detect if device supports double-click, , if does, great, if doesn't fall preference instead.

i tried once , failed. tried detecting if device supports touch (using modernizr), that's wrong, because computers support both double-click , touch, in case want still let people double-click. (supporting touch not opposite of supporting double-click)

is there way tell if browser/device combo supports traditional double-click?

no, outside of prompting user attempt perform action , detecting if single or double click occurs, there not (yet) cross device standard detecting available input methods.

you could, on other hand, attempt use detection library modernizr (http://modernizr.com/docs/) detect if on touch device, , swtich detecting , actual doubleclick detecting clicks within frequency. following:

var d = new date(); var lastclick = d.gettime(); var clickdelay = 500; //half second if(modernizr.touch){ body.click(function(){   var currentclick = d.gettime();   if(currentclick - lastclick < clickdelay){   lastclick = 0; //prevent tripleclick registering   //doubleclick detected,   } }); } else /*use current doubleclick detection*/ { //do } 

i oversimplifying, in example want detecting touch events rather clicks, should give general idea.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -