DEV Community

Rounit Ranjan Sinha
Rounit Ranjan Sinha

Posted on

Pointer events in JS

While practicing JS or mostly while making projects with JS we all have used "mouse" events, like onmousedown, onmouseover, ...onmouse etc

These mouse events are for desktop only apps but for mobile & tablets we use touch events like touchmove, touchcancel, touchover etc.

We can use both at a same time but that makes code bulkier and it's hard to use both at same time.

To resolve this we can use the pointer events of JS which has
*unique PointerId
*height,
*width,
*tiltX,
*tiltY,
*twist etc like properties..

Events are:
pointerdown, pointerup, pointercancel, pointerover etc

In the image I have attached, it's clear that
the pointer type is "touch", which was detected by the event itself
and above that there is unique pointerId present

Image description

Top comments (0)