The PointerEvent()
constructor creates a new synthetic and untrusted PointerEvent
object instance.
On this page
PointerEvent: PointerEvent() constructor
Syntax
js
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'sPointerEvent.pointerId
. -
width
-
A number,, defaulting to
1
, that sets the value of the instance'sPointerEvent.width
. -
height
-
A number,, defaulting to
1
, that sets the value of the instance'sPointerEvent.height
. -
pressure
-
A number, defaulting to
0
, that sets the value of the instance'sPointerEvent.pressure
. -
tangentialPressure
-
A number, defaulting to
0
, that sets the value of the instance'sPointerEvent.tangentialPressure
. -
tiltX
-
A number, defaulting to
0
, that sets the value of the instance'sPointerEvent.tiltX
. -
tiltY
-
A number, defaulting to
0
, that sets the value of the instance'sPointerEvent.tiltY
. -
twist
-
A number, defaulting to
0
, that sets the value of the instance'sPointerEvent.twist
. -
pointerType
-
A string, defaulting to
""
that sets the value of the instance'sPointerEvent.pointerType
. -
isPrimary
-
A boolean value, defaulting to
false
that sets the value of the instance'sPointerEvent.isPrimary
.
-
Return value
A new PointerEvent
object.
Examples
js
const moveEvent = new PointerEvent("pointermove");
const 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
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
10See MSDN Pointer events updates. |
42 | 13 | 55 | 55 | 79 | 42 | 13 | 6.0 |
© 2005–2023 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