DEV Community

zhangbao
zhangbao

Posted on • Updated on

What is Pointer Events in JavaScript

Roughly, You can think Pointer Events as a combination of Mouse and Touch events.

document.addEventListener('mousedown', () => {
  // do something on mousedown
});

document.addEventListener('touchstart', () => {
  // do something on touchstart
});
Enter fullscreen mode Exit fullscreen mode

same as below

document.addEventListener('pointerdown', () => {
  // do something on mousedown or touchstart
});
Enter fullscreen mode Exit fullscreen mode

Reference:

Read more:

Top comments (0)