Created
June 25, 2016 15:52
-
-
Save wkw/4d8a533193bc032ee0eaab94bd64f0d8 to your computer and use it in GitHub Desktop.
Detect mobile devices by presence of touch handlers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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