First, we're going to declare a
function that we will ask to be called for touch events.
Recall that we are given an array of touch points, one for each finger. So we'll need to
go through each element of the array using a for-loop.
We'll also make use of preventDefault, otherwise the device might make the screen slide around because
it thinks we're trying to scroll.
function MyTouchHandler (MyEvent) {
for (var i=0; i < MyEvent.touches.length; i++) {
}
MyEvent.preventDefault();
}
We'll also connect up some listeners. In this case, we want our handler to be called
whether a touch is starting, ending, or moving.
addEventListener("touchstart", MyTouchHandler);
addEventListener("touchmove", MyTouchHandler);
addEventListener("touchend", MyTouchHandler);