PointerEvent

ThePointerEventinterface 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.

Apointeris 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'shit testis 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.

Event UIEvent MouseEvent PointerEvent

Constructors

PointerEvent()

Creates a synthetic—and untrusted—PointerEvent.

Instance properties

This interface inherits properties fromMouseEventandEvent.

PointerEvent.altitudeAngleRead only Experimental

Represents the angle between a transducer (a pointer or stylus) axis and the X-Y plane of a device screen.

PointerEvent.azimuthAngleRead only Experimental

Represents the angle between the Y-Z plane and the plane containing both the transducer (a pointer or stylus) axis and the Y axis.

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 range0to1,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 orcylinder 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 range0to359.

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.

Instance methods

PointerEvent.getCoalescedEvents()Secure context

Returns a sequence of allPointerEventinstances that were coalesced into the dispatchedpointermoveevent.

PointerEvent.getPredictedEvents()

Returns a sequence ofPointerEventinstances that the browser predicts will follow the dispatchedpointermoveevent's coalesced events.

Pointer event types

ThePointerEventinterface has several event types. To determine which event fired, look at the event'stypeproperty.

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 callpreventDefault()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 apointerdownevent from a device that does not support hover (seepointerdown). This event type is similar topointerover,but differs in that it does not bubble.

pointerdown

The event is fired when a pointer becomesactive.For mouse, it is fired when the device transitions from no buttons pressed to at least one button pressed. 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.

Note:For touchscreen browsers that allowdirect manipulation,apointerdownevent triggersimplicit pointer capture,which causes the target to capture all subsequent pointer events as if they were occurring over the capturing target. Accordingly,pointerover,pointerenter,pointerleave,andpointeroutwill not fireas long as this capture is set. The capture can be released manually by callingelement.releasePointerCaptureon the target element, or it will be implicitly released after apointeruporpointercancelevent.

pointermove

This event is fired when a pointer changes coordinates.

pointerrawupdate Experimental

This event is fired when any of a pointer's properties change.

pointerup

This event is fired when a pointer is no longeractive.

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 deactivated).

pointerout

This event is fired for several reasons including: pointing device is moved out of the hit test boundaries of an element; firing thepointerupevent 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.

Example

Examples of each property, event type, and global event handler are included in their respective reference pages.

Specifications

Specification
Pointer Events
#pointerevent-interface

Browser compatibility

BCD tables only load in the browser

See also