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.pointerIdRead only- A unique identifier for the pointer causing the event.
PointerEvent.widthRead only- The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer.
PointerEvent.heightRead only- The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer.
PointerEvent.pressureRead only- The normalized pressure of the pointer input in the range
0to1, where0and1represent the minimum and maximum pressure the hardware is capable of detecting, respectively. PointerEvent.tangentialPressureRead only- The normalized tangential pressure of the pointer input (also known as barrel pressure or cylinder stress) in the range
-1to1, where0is the neutral position of the control. PointerEvent.tiltXRead only- The plane angle (in degrees, in the range of
-90to90) between the Y–Z plane and the plane containing both the pointer (e.g. pen stylus) axis and the Y axis. PointerEvent.tiltYRead only- The plane angle (in degrees, in the range of
-90to90) between the X–Z plane and the plane containing both the pointer (e.g. pen stylus) axis and the X axis. PointerEvent.twistRead only- The clockwise rotation of the pointer (e.g. pen stylus) around its major axis in degrees, with a value in the range
0to359. PointerEvent.pointerTypeRead only- Indicates the device type that caused the event (mouse, pen, touch, etc.)
PointerEvent.isPrimaryRead only- Indicates if the pointer represents the primary pointer of this pointer type.
Methods
PointerEvent.getCoalescedEvents()'- Returns a sequence of all
PointerEventinstances that were coalesced into the dispatchedpointermoveevent. PointerEvent.getPredictedEvents()'- Returns a sequence of
PointerEventinstances that the browser predicts will follow the dispatchedpointermoveevent's coalesced events.
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.
pointerrawupdate'- This event is fired when any of a pointer's properties change.
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
pointerupevent for a device that does not support hover (seepointerup); after firing thepointercancelevent (seepointercancel); 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 handlerfor thepointeroverevent. GlobalEventHandlers.onpointerenter- A
global event handlerfor thepointerenterevent. GlobalEventHandlers.onpointerdown- A
global event handlerfor thepointerdownevent. GlobalEventHandlers.onpointermove- A
global event handlerfor thepointermoveevent. GlobalEventHandlers.onpointerup- A
global event handlerfor thepointerupevent. GlobalEventHandlers.onpointercancel- A
global event handlerfor thepointercancelevent. GlobalEventHandlers.onpointerout- A
global event handlerfor thepointeroutevent. GlobalEventHandlers.onpointerleave- A
global event handlerfor thepointerleaveevent.
Example
Examples of each property, event type, and global event handler are included in their respective reference pages.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Pointer Events – Level 3The definition of 'PointerEvent' in that specification. | Editor's Draft | Added the getCoalescedEvents() and getPredictedEvents() methods and pointerrawupdate event.
|
| Pointer Events – Level 2The definition of 'PointerEvent' in that specification. | Recommendation | Added the twist and tangentialPressure properties.
|
| Pointer EventsThe definition of 'PointerEvent' in that specification. | Obsolete | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
PointerEvent
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE Full support 11 Full support 11 Partial support 10 Prefixed' Implemented with the vendor prefix: MS Notes' See MSDN Pointer events updates. |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
PointerEvent() constructor
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE Full support 11 Full support 11 Partial support 10 Prefixed' Implemented with the vendor prefix: MS Notes' See MSDN Pointer events updates. |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
| Chrome
Full support 58 |
Edge
Full support 79 |
Firefox
Full support 59 |
IE
No support No |
Opera
Full support 45 |
Safari
No support No |
WebView Android
Full support 58 |
Chrome Android
Full support 58 |
Firefox Android Partial support 59 Partial support 59 Disabled' From version 59: this feature is behind the |
Opera Android
Full support 43 |
Safari iOS
No support No |
Samsung Internet Android
Full support 7.0 | |
height
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE Full support 11 Full support 11 Partial support 10 Notes' Returns values in screen pixels instead of CSS document pixels. |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
isPrimary
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE
Full support 10 |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
pointerId
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE
Full support 10 |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
pointerType
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE Full support 11 Full support 11 Partial support 10 Notes' Returns an integer enumeration instead of a string. |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
pressure
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE Full support 11 Full support 11 Partial support 10 Notes' Returns 0 instead of 0.5 on hardware that doesn't support pressure. |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
tangentialPressure
|
Chrome
Full support 58 |
Edge
Full support 79 |
Firefox Full support 59 Full support 59 Full support 54 Disabled' From version 54: this feature is behind the |
IE
No support No |
Opera
Full support 45 |
Safari
Full support 13 |
WebView Android
Full support 58 |
Chrome Android
Full support 58 |
Firefox Android Full support 54 Full support 54 Disabled' From version 54: this feature is behind the |
Opera Android
Full support 43 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 7.0 |
tiltX
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE
Full support 10 |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
tiltY
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE
Full support 10 |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
twist
|
Chrome
Full support 58 |
Edge
Full support 18 |
Firefox Full support 59 Full support 59 Full support 54 Disabled' From version 54: this feature is behind the |
IE
No support No |
Opera
Full support 45 |
Safari
Full support 13 |
WebView Android
Full support 58 |
Chrome Android
Full support 58 |
Firefox Android Full support 54 Full support 54 Disabled' From version 54: this feature is behind the |
Opera Android
Full support 43 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 7.0 |
width
|
Chrome
Full support 55 |
Edge
Full support 12 |
Firefox Full support 59 Full support 59 Full support 41 Disabled' From version 41: this feature is behind the |
IE Full support 11 Full support 11 Partial support 10 Notes' Returns values in screen pixels instead of CSS document pixels. |
Opera
Full support 42 |
Safari
Full support 13 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Opera Android
Full support 42 |
Safari iOS
Full support 13 |
Samsung Internet Android
Full support 6.0 |
Legend
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
PointerEvent by Mozilla Contributors is licensed under CC-BY-SA 2.5.