TouchEvent adaptor - adapts touch events into mouse events
JavaScript CoffeeScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

TouchEvents translator

Translate touch events into custom mouse events. Technique by Ross Boucher -


Initialize touch events for a selector:


The document.getElementById style also works.


Devices that emit touch events in response to user touches will translate them into mouse events for you, but there's a catch: if you rely on the mousemove event while the mouse button is down, the events might not fire in the order you expect.

This technique intercepts the touch events and generates custom mouse events in the same order. This makes techniques involving mousemove, such as dragging, more predictable across devices.