PointerEvent()

The PointerEvent() constructor creates a new synthetic and untrusted PointerEvent object instance.

Syntax

new PointerEvent(type)
new PointerEvent(type, options)

Parameters

type

A string representing the name of the event (see PointerEvent event types).

options Optional

An object that, in addition of the properties defined in MouseEvent(), can have the following properties:

pointerId

A number, defaulting to 0, that sets the value of the instance's PointerEvent.pointerId.

width

A number,, defaulting to 1, that sets the value of the instance's PointerEvent.width.

height

A number,, defaulting to 1, that sets the value of the instance's PointerEvent.height.

pressure

A number, defaulting to 0, that sets the value of the instance's PointerEvent.pressure.

tangentialPressure

A number, defaulting to 0, that sets the value of the instance's PointerEvent.tangentialPressure.

tiltX

A number, defaulting to 0, that sets the value of the instance's PointerEvent.tiltX.

tiltY

A number, defaulting to 0, that sets the value of the instance's PointerEvent.tiltY.

twist

A number, defaulting to 0, that sets the value of the instance's PointerEvent.twist.

pointerType

A string, defaulting to "" that sets the value of the instance's PointerEvent.pointerType.

isPrimary

A boolean value, defaulting to false that sets the value of the instance's PointerEvent.isPrimary.

Return value

A new PointerEvent object.

Examples

var moveEvent = new PointerEvent("pointermove");

var downEvent = new PointerEvent("pointerdown",
   {pointerId: 1,
    bubbles: true,
    cancelable: true,
    pointerType: "touch",
    width: 100,
    height: 100,
    isPrimary: true
   });

Specifications

Specification
Pointer Events
# dom-pointerevent-constructor

Browser compatibility

BCD tables only load in the browser