Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Checking for touch support
<!doctype html>
<title>has touch?</title>
<h1>Has this device touch? </h1>
var isTouch = (function(){
var event = document.createEvent("TouchEvent"); // Should throw an error if not supported
return !!event.initTouchEvent; // Check for existance of initialization method
return false;
document.getElementsByTagName("h1")[0].innerHTML += isTouch ? "yes" : "no";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.