Skip to content

Instantly share code, notes, and snippets.

@thingsinjars
Created October 20, 2010 08:33
Show Gist options
  • Save thingsinjars/636030 to your computer and use it in GitHub Desktop.
Save thingsinjars/636030 to your computer and use it in GitHub Desktop.
Quick summary of some Touch Events
document.ontouchstart = function(e) {
//This will alert coordinates where you touch the screen
alert(e.touches[0].pageX+', '+e.touches[0].pageY);
//This will alert coordinates if you touch with a second finger at the same time
if(e.touches[1]) {
alert(e.touches[1].pageX+', '+e.touches[1].pageY);
}
}
document.ontouchmove = function(e) {
alert(e.touches[0].pageX+', '+e.touches[0].pageY);
}
document.ontouchend = function(e) {
//This one doesn't have coordinates
alert('Finger lifted');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment