The PointerEvent()
constructor creates a new synthetic and untrusted PointerEvent
object instance.
PointerEvent()
Syntax
new PointerEvent(type, PointerEventInit);
Arguments
- type
-
Is a
DOMString
representing the name of the event (see PointerEvent event types). - PointerEventInit Optional
-
Is a
PointerEventInit
dictionary, having the following fields:-
pointerId
— optionallong
, defaulting to0
, sets the value of the instance'sPointerEvent.pointerId
. -
width
— optionaldouble
, defaulting to1
, sets the value of the instance'sPointerEvent.width
. -
height
— optionaldouble
, defaulting to1
, sets the value of the instance'sPointerEvent.height
. -
pressure
— optionalfloat
, defaulting to0
, sets the value of the instance'sPointerEvent.pressure
. -
tangentialPressure
— optionalfloat
, defaulting to0
, sets the value of the instance'sPointerEvent.tangentialPressure
. -
tiltX
— optionallong
, defaulting to0
, sets the value of the instance'sPointerEvent.tiltX
. -
tiltY
— optionallong
, defaulting to0
, sets the value of the instance'sPointerEvent.tiltY
. -
twist
— optionallong
, defaulting to0
, sets the value of the instance'sPointerEvent.twist
. -
pointerType
— optionalDOMString
, defaulting to""
sets the value of the instance'sPointerEvent.pointerType
. -
isPrimary
— optional boolean value, defaulting tofalse
sets the value of the instance'sPointerEvent.isPrimary
.
Note: The
PointerEventInit
dictionary also accepts fields from theMouseEvent
,UIEventInit
andEventInit
dictionaries. -
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 });
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
PointerEvent |
55
|
12
|
59
|
11
10
|
42
|
13
|
55
|
55
|
79
|
42
|
13
|
6.0
|
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent