Created
January 14, 2019 10:19
-
-
Save sergixnet/a515d37b10831808da55f3a19b20c7b9 to your computer and use it in GitHub Desktop.
Detect if is mobile or touch device
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
const isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i); | |
const isTouch = isMobile !== null || document.createTouch !== undefined || ('ontouchstart' in window) || ('onmsgesturechange' in window) || navigator.msMaxTouchPoints; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment