How to detect a touchscreen


Discussion on StackOverflow about how to detect a touchscreen

The discussion begins with using the Modernizr library, which tests for touch events in the browser; but notes that since Windows 8 was released some browsers have been erroneously reporting touch support. A number of other alternatives are under discussion.

Best latest version appears to be:

function is_touch_device() {
  return 'ontouchstart' in window // works on most browsers 
      || 'onmsgesturechange' in window; // works on ie10

Leave a Reply

Your email address will not be published. Required fields are marked *