Modernizr.touch returns true on firefox browser

Sameera Thilakasiri picture Sameera Thilakasiri · Feb 28, 2014 · Viewed 7.9k times · Source

I have written a peace of code to get the event based on touch and non-touch. Its working all other browsers and devices, but Firefox. Default FF return the true.

var thumbsEvent, isTouch = Modernizr.touch; // detect the touch
if(isTouch){
   thumbsEvent = 'click';//on touch surface, click
}
else {
   thumbsEvent = 'mouseover';//on non touch surface, mouseover
}

Is there a way to manage this issue.

Example fiddle

Answer

Patrick picture Patrick · Feb 28, 2014

On behalf of Modernizr - We're really sorry about this.

Modernizr.touch has been renamed Modernizr.touchevents in the yet-to-be-released version 3.0, as it is a far more accurate description of the detect. Basically, all this detect is doing is checking for the existence of touch events, and returning true if they are found. Desktop chrome does the same thing if you enable developer tools. It just means that your version of firefox on your laptop is reporting support of touch events, for several possible reasons.