The PointerEvent()
constructor creates a new synthetic and untrusted PointerEvent
object instance.
Syntax
event = new PointerEvent(type, PointerEventInit);
Arguments
- type
- Is a
DOMString
representing the name of the event (see PointerEvent event types). - PointerEventInitOptional
- Is a
PointerEventInit
dictionary, having the following fields:pointerId
— optional and defaulting to0
, of typelong
, that sets the value of the instance'sPointerEvent.pointerId
.width
— optional and defaulting to1
, of typedouble
, that sets the value of the instance'sPointerEvent.width
.height
— optional and defaulting to1
, of typedouble
, that sets the value of the instance'sPointerEvent.height
.pressure
— optional and defaulting to0
, of typefloat
, that sets the value of the instance'sPointerEvent.pressure
.tangentialPressure
— optional and defaulting to0
, of typefloat
, that sets the value of the instance'sPointerEvent.tangentialPressure
.tiltX
— optional and defaulting to0
, of typelong
, that sets the value of the instance'sPointerEvent.tiltX
.tiltY
— optional and defaulting to0
, of typelong
, that sets the value of the instance'sPointerEvent.tiltY
.twist
— optional and defaulting to0
, of typelong
, that sets the value of the instance'sPointerEvent.twist
.pointerType
— optional and defaulting to""
, of typeDOMString
, that sets the value of the instance'sPointerEvent.pointerType
.isPrimary
— optional and defaulting tofalse
, of typeBoolean
, that sets the value of the instance'sPointerEvent.isPrimary
.
Note: The
PointerEventInit
dictionary also accepts fields from theMouseEvent
,UIEventInit
andEventInit
dictionaries.
Example
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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
PointerEvent() constructor | Chrome Full support 55 | Edge Full support 12 | Firefox
Full support
59
| IE
Full support
11
| Opera Full support 42 | Safari Full support 13 | WebView Android Full support 55 | Chrome Android Full support 55 | Firefox Android
Full support
41
| Opera Android Full support 42 | Safari iOS Full support 13 | Samsung Internet Android Full support 6.0 |
Legend
- Full support
- Full support
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.