Game Development Reference
In-Depth Information
document.body.addEventListener("touchstart",
doOnTouchStart);
function doOnTouchStart(event) {
event.preventDefault();
// ...
}
The object passed into the registered callback function is an instance of the
TouchEvent class, which contains the following attributes:
touches
An instance of the TouchList class which looks like an ordinary array and contains
a list of all touches that have been touched down on the touch device and have not
yet been removed, even if other active touches have moved about the screen or in-
put device. Each element in this list is an instance of type Touch .
changedTouches
An instance of the TouchList class containing a list of touch objects representing
all new touch points that have been introduced since the last touch event. For ex-
ample, if two touch objects have already been detected (in other words, two fingers
have been pressed against the touch device) and a third touch is detected, only this
third touch is present in this touch list. Again, every touch-related element contained
by this touch list is of type Touch .
targetTouches
An instance of the TouchList class containing a list of touch objects representing
all touch points that have been captured by a given DOM node. For example, if mul-
tiple touches have been detected throughout the screen but a particular element re-
gistered for a touch start event and captured this event (either from the capture or
bubble stage), only touch events captured by this node will be present in this touch
list. Again, every touch-related element contained by this touch list is of type Touch .
Search WWH ::




Custom Search