W3cubDocs

/DOM

PointerEvent

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.

Constructors

PointerEvent()
Creates a synthetic and untrusted PointerEvent.

Properties

This interface inherits properties from MouseEvent and Event.

PointerEvent.pointerId Read only
A unique identifier for the pointer causing the event.
PointerEvent.width Read only
The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer.
PointerEvent.height Read only
The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer.
PointerEvent.pressure Read only
The normalized pressure of the pointer input in the range 0 to 1, where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively.
PointerEvent.tangentialPressure Read only
The normalized tangential pressure of the pointer input (also known as barrel pressure or cylinder stress) in the range -1 to 1, where 0 is the neutral position of the control.
PointerEvent.tiltX Read only
The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane and the plane containing both the transducer (e.g. pen stylus) axis and the Y axis.
PointerEvent.tiltY Read only
The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane and the plane containing both the transducer (e.g. pen stylus) axis and the X axis.
PointerEvent.twist Read only
The clockwise rotation of the transducer (e.g. pen stylus) around its major axis in degrees, with a value in the range 0 to 359.
PointerEvent.pointerType Read only
Indicates the device type that caused the event (mouse, pen, touch, etc.)
PointerEvent.isPrimary Read only
Indicates if the pointer represents the primary pointer of this pointer type.

Methods

PointerEvent.getCoalescedEvents()
Returns a sequence of all PointerEvent instances that were coalesced into the dispatched pointermove event.

Pointer event types

The PointerEvent interface has several event types. To determine which event fired, look at the event's type property.

Note: It's important to note that in many cases, both pointer and mouse events get sent (in order to let non-pointer-specific code still interact with the user). If you use pointer events, you should call event.preventDefault() to keep the mouse event from being sent as well.
pointerover
This event is fired when a pointing device is moved into an element's hit test boundaries.
pointerenter
This event is fired when a pointing device is moved into the hit test boundaries of an element or one of its descendants, including as a result of a pointerdown event from a device that does not support hover (see pointerdown). This event type is similar to pointerover, but differs in that it does not bubble.
pointerdown
The event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
pointermove
This event is fired when a pointer changes coordinates.
pointerup
This event is fired when a pointer is no longer active.
pointercancel
A browser fires this event if it concludes the pointer will no longer be able to generate events (for example the related device is deactived).
pointerout
This event is fired for several reasons including: pointing device is moved out of the hit test boundaries of an element; firing the pointerup event for a device that does not support hover (see pointerup); after firing the pointercancel event (see pointercancel); when a pen stylus leaves the hover range detectable by the digitizer.
pointerleave
This event is fired when a pointing device is moved out of the hit test boundaries of an element. For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer.
gotpointercapture
This event is fired when an element receives pointer capture.
lostpointercapture
This event is fired after pointer capture is released for a pointer.

GlobalEventHandlers

GlobalEventHandlers.onpointerover
A global event handler for the pointerover event.
GlobalEventHandlers.onpointerenter
A global event handler for the pointerenter event.
GlobalEventHandlers.onpointerdown
A global event handler for the pointerdown event.
GlobalEventHandlers.onpointermove
A global event handler for the pointermove event.
GlobalEventHandlers.onpointerup
A global event handler for the pointerup event.
GlobalEventHandlers.onpointercancel
A global event handler for the pointercancel event.
GlobalEventHandlers.onpointerout
A global event handler for the pointerout event.
GlobalEventHandlers.onpointerleave
A global event handler for the pointerleave event.

Example

An Example of each property, event type and global event handler is included in their respective reference page.

Specifications

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.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Prefixed
Prefixed Implemented with the vendor prefix: MS
See MSDN Pointer events updates.
42 No
PointerEvent() constructor 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Prefixed
Prefixed Implemented with the vendor prefix: MS
See MSDN Pointer events updates.
42 No
pointerId 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
10 42 No
width 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Returns values in screen pixels instead of CSS document pixels.
42 No
height 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Returns values in screen pixels instead of CSS document pixels.
42 No
pressure 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Returns 0 instead of 0.5 on hardware that doesn't support pressure.
42 No
tangentialPressure 58 No 59
59
54
Disabled
Disabled From version 54: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No 45 No
tiltX 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
10 42 No
tiltY 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
10 42 No
twist 58 No 59
59
54
Disabled
Disabled From version 54: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No 45 No
pointerType 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
10
Returns an integer enumeration instead of a string.
42 No
isPrimary 55 12 59
59
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
10 42 No
getCoalescedEvents 58 No 59 No 45 No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
PointerEvent() constructor 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
pointerId 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
width 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
height 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
pressure 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
tangentialPressure 58 58 No No
No
54
Disabled
Disabled From version 54: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
45 No 7.0
tiltX 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
tiltY 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
twist 58 58 No No
No
54
Disabled
Disabled From version 54: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
45 No 7.0
pointerType 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
isPrimary 55 55 12 No
No
41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
42 No 6.0
getCoalescedEvents 58 58 No No 45 No 7.0

See also

© 2005–2018 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