If you are working on a mobile HTML5 website / app you probably want to know what are the javascript events you can use based on the user interaction. Well, here is a list (cheatsheet); bellow is a table comparing the mobile javascript events with their desktop counterparts. The “composed” column shows similar mobile events that may also be triggered.
| Action | Desktop | Mobile | Composed |
|---|---|---|---|
| Mouse down | onmousedown | touchstart | |
| Mouse move | onmousemove | touchmove | |
| Mouse up | onmouseup | touchend | |
| Click | onclick | touchstart + touchend | |
| Double click | ondblclick | touchstart + touchend + touchstart + touchend | |
| Drag | onmousedown + onmousemove + onmouseup | touchstart + touchmove + touchend | |
| Mouse over | onmouseover | touchenter | touchstart + touchmove |
| Mouse out | onmouseout | touchleave | touchenter + touchmove |
| Tab two fingers start pinch / zoom | gesturestart | touchstart + touchmove | |
| Pinch / zoom | gesturechange | gesturestart + touchmove | |
| Stop pinch / zoom | gestureend | touchmove + touchend | |
| Pinch / zoom interruption | touchcancel | ||
| Rotate device | orientationchange |
If you have any questions please leave a comment bellow.
