Skip to content

Instantly share code, notes, and snippets.

@phalkunz
Created October 8, 2013 09:32
Show Gist options
  • Save phalkunz/6882118 to your computer and use it in GitHub Desktop.
Save phalkunz/6882118 to your computer and use it in GitHub Desktop.
Touch event detection
// Source: https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/
if (
('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0) ||
(navigator.msMaxTouchPoints > 0)
) {
/* browser with either Touch Events of Pointer Events
running on touch-capable device */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment