Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Created April 30, 2013 10:49
Show Gist options
  • Select an option

  • Save jasdeepkhalsa/5487971 to your computer and use it in GitHub Desktop.

Select an option

Save jasdeepkhalsa/5487971 to your computer and use it in GitHub Desktop.
Detect if a device has touch enabled with JavaScript
function is_touch_device() {
return !!('ontouchstart' in window) // works on most browsers
|| !!('onmsgesturechange' in window); // works on ie10
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment