Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<title>TouchEvent detection for iPhone/iPod/iPad</title>
<script type="text/javascript">
var isTouch = (function() {
var event, feature = false,
support = function() { feature = true; },
element = document.createElement('div');
try {
event = document.createEvent('TouchEvent'),
event.initTouchEvent('touchstart', true, true, document.defaultView);
element.addEventListener('touchstart', support, false);
} catch(e) {
feature = false;
return feature;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment