The PointerEvent
interface represents the state of a DOM event produced by a pointer such as the geometry of the contact point, the device type that generated the event, the amount of pressure that was applied on the contact surface, etc.
A pointer is a hardware agnostic representation of input devices (such as a mouse, pen or contact point on a touch-enable surface). The pointer can target a specific coordinate (or set of coordinates) on the contact surface such as a screen.
A pointer's hit test is the process a browser uses to determine the target element for a pointer event. Typically, this is determined by considering the pointer's location and also the visual layout of elements in a document on screen media.
PointerEvent()
This interface inherits properties from MouseEvent
and Event
.
PointerEvent.pointerId
Read only
PointerEvent.width
Read only
PointerEvent.height
Read only
PointerEvent.pressure
Read only
PointerEvent.tiltX
Read only
PointerEvent.tiltY
Read only
PointerEvent.pointerType
Read only
PointerEvent.isPrimary
Read only
The PointerEvent
interface has several event types. To determine which event fired, look at the event's type
property.
event.preventDefault()
to keep the mouse event from being sent as well.pointerover
pointerenter
pointerdown
pointermove
pointerup
pointercancel
pointerout
pointerleave
gotpointercapture
lostpointercapture
GlobalEventHandlers.onpointerover
global event handler
for the pointerover
event.GlobalEventHandlers.onpointerenter
global event handler
for the pointerenter
event.GlobalEventHandlers.onpointerdown
global event handler
for the pointerdown
event.GlobalEventHandlers.onpointermove
global event handler
for the pointermove
event.GlobalEventHandlers.onpointerup
global event handler
for the pointerup
event.GlobalEventHandlers.onpointercancel
global event handler
for the pointercancel
event.GlobalEventHandlers.onpointerout
global event handler
for the pointerout
event.GlobalEventHandlers.onpointerleave
global event handler
for the pointerleave
event.An Example of each property, event type and global event handler is included in their respective reference page.
Specification | Status | Comment |
---|---|---|
Pointer Events – Level 2 The definition of 'PointerEvent' in that specification. | Working Draft | Non-stable version. |
Pointer Events The definition of 'PointerEvent' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 55.0 | (Yes) | No support [1] | 10ms 11 | 42 | No support |
touch-action property | (Yes) | ? | No support [2] | 11 | (Yes) | No support |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|---|
Basic support | No support | 55.0 | (Yes) | No support [1] | No support | 10 | 42 | No support | 55.0 |
touch-action property | No support | (Yes) | ? | No support [3] | No support | (Yes) | No support | (Yes) |
[1] This feature is currently hidden behind a flag; to enable it and experiment, set the dom.w3c_pointer_events.enabled
preference to true
in about:config
.
[2] Starting in Firefox 29, touch-action
is implemented in Firefox, but is hidden behind the layout.css.touch_action.enabled
preference. Starting in Firefox Nighly 50, it is enabled by default when running in nightly builds only; no decision has been made on when it will make its way along toward release. You still need to separately enable the dom.w3c_pointer_events.enabled
preference, however.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent