Skip to content

Instantly share code, notes, and snippets.

@robspangler
Created May 10, 2013 14:29
Show Gist options
  • Save robspangler/5554753 to your computer and use it in GitHub Desktop.
Save robspangler/5554753 to your computer and use it in GitHub Desktop.
Detects touch screen using Javascript with Modernizr and gives you a handy re-usable variable. Also added an iPad specific variable.
var isTouch = Modernizr.touch != false;
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if (isTouch)
alert('Touch');
if (isiPad)
alert('iPad');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment