Syntax
Use the event name in methods like addEventListener(), or set an event handler property.
js
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():
js
const para = document.querySelector("p");
para.addEventListener("pointermove", (event) => {
console.log("Pointer moved");
});
You can also use the onpointermove event handler property:
js
const para = document.querySelector("p");
para.onpointermove = (event) => {
console.log("Pointer moved");
};
Specifications
| Specification |
|---|
| Pointer Events # the-pointermove-event |
| Pointer Events # dom-globaleventhandlers-onpointermove |