Skip to content

Instantly share code, notes, and snippets.

@qjleely
Created December 11, 2013 02:30
Show Gist options
  • Save qjleely/7904255 to your computer and use it in GitHub Desktop.
Save qjleely/7904255 to your computer and use it in GitHub Desktop.
A Pen by qj.
//http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript
function is_touch_device() {
return 'ontouchstart' in window // works on most browsers
|| 'onmsgesturechange' in window; // works on ie10
};
console.log('is touch device: ' + is_touch_device());
document.write('is touch device: ' + is_touch_device());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment