docs.rodeo

MDN Web Docs mirror

PointerEvent

{{ APIRef("Pointer Events") }} 

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.

{{InheritanceDiagram}} 

Constructors

Instance properties

This interface inherits properties from {{domxref("MouseEvent")}}  and {{domxref("Event")}} .

Instance methods

Pointer event types

The PointerEvent interface has several event types. To determine which event fired, look at the event’s {{domxref("Event.type", "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 {{domxref("Event.preventDefault()", "preventDefault()")}}  to keep the mouse event from being sent as well.

Example

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

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN