Pages

Thursday 12 September 2013

windows devices detect touch events present




Hello guys


As usual, Microsoft gives different names for the same thing just to make harder for us developers.

First we tried to detect if windows devices have touch by using "window.navigator.msPointerEnabled".

Then I noticed that Internet Explorer 10 on desktop report something other than "undefined".

The correct way to detect is by using "window.navigator.msMaxTouchPoints". It returns "undefined" for desktops or the number of touches supported by the device.

Tested on a few Nokia Lumia devices and Surface.

My final function is something like this:


    hasTouch: function() {
       return Modernizr.touch || !!window.navigator.msMaxTouchPoints;
    },



I hope future Modernizr version does this job for us soon.

more details about MS touch: http://msdn.microsoft.com/en-us/library/ie/hh920754(v=vs.85).aspx


cheers
Leonardo Correa



No comments:

Post a Comment