chrisstump
2/8/18 at 10:38 am
JavaScript
Detect Touch Enabled Device
Use this simple JavaScript function to detect whether the current device is a touch enabled device.
// see more detailed information here // https://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript function isTouchEnabledDevice() { return 'ontouchstart' in window // works on most browsers || navigator.maxTouchPoints; // works on IE10/11 and Surface }
Copy Snippet to Clipboard
Don't Have an Account?
Stop digging through old code examples. Get organized. Get Code Snipper.
Learn More
Start Free 14 Day Trial