Element: pointermove event
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
The pointermove event is fired when a pointer changes coordinates, and the pointer has not been canceled by a browser touch-action. It's very similar to the mousemove event, but with more features.
These events happen whether or not any pointer buttons are pressed. They can fire at a very high rate, depends on how fast the user moves the pointer, how fast the machine is, what other tasks and processes are happening, etc.
Syntax
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("pointermove", (event) => { })
onpointermove = (event) => { }
Event type
A PointerEvent. Inherits from Event.
Usage notes
The event, which is of type PointerEvent, provides all the information you need to know about the user's interaction with the pointing device, including the position, movement distance, button states, and much more.
Examples
To add a handler for pointermove events using addEventListener():
const para = document.querySelector("p");
para.addEventListener("pointermove", (event) => {
console.log("Pointer moved");
});
You can also use the onpointermove event handler property:
const para = document.querySelector("p");
para.onpointermove = (event) => {
console.log("Pointer moved");
};
Specifications
| Specification |
|---|
| Pointer Events> # the-pointermove-event> |
| Pointer Events> # dom-globaleventhandlers-onpointermove> |