Handle touch events in web application

To handle touch events in your web applications you can create listeners for touch events (touchstart, touchmove, touchend).
// code (main.js):
var obj = document.getElementById('id');

// sent when user places a touch point
obj.addEventListener('touchstart', function(event) {
	console.log(event);
}, false);

// sent when user moves touch point
obj.addEventListener('touchmove', function(event) {
	console.log(event);
}, false);

// sent when user removes a touch point
obj.addEventListener('touchend', function(event) {
	console.log(event);
}, false);

Responses

0 Replies