touchcancel Event
Example
Execute a JavaScript when a touch is interrupted (for touch screens only):
<p ontouchcancel="myFunction(event)">Touch me!</p>
Try it Yourself »
Definition and Usage
The touchcancel event occurs when the touch event gets interrupted.
Different devices will interrupt a touch event at different actions, and it is considered good practice to include this event to clean up code if this "error" should occur.
Note: The touchstart event will only work on devices with a touch screen.
Tip: Other events related to the touchstart event are:
- touchstart - occurs when the user touches an element
- touchend - occurs when the user removes the finger from an element
- touchmove - occurs when the user moves the finger across the screen
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
touchcancel | 22.0 | 12.0 | 52 | Not supported | Not supported |
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("touchcancel", myScript);
Try it Yourself »
Technical Details
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | TouchEvent |
Supported HTML tags: | All HTML elements |