PointerEvent()
The PointerEvent()
constructor creates a new synthetic and untrusted PointerEvent
.
Syntax
JavaScript
Copy Code
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 to"0"
, of typelong
, that sets the value ofPointerEvent
."width"
, optional and defaulting to"0"
, of typedouble
, that sets the value ofPointerEvent
."height"
, optional and defaulting to"0"
, of typedouble
, that sets the value ofPointerEvent
."pressure"
, optional and defaulting to"0"
, of typefloat
, that sets the value ofPointerEvent
."tiltX"
, optional and defaulting to"0"
, of typelong
, that sets the value ofPointerEvent
."tiltY"
, optional and defaulting to"0"
, of typelong
, that sets the value ofPointerEvent
."pointerType"
, optional and defaulting to""
, of typeDOMString
, that sets the value ofPointerEvent
."isPrimary"
, optional and defaulting to"false"
, of typeBoolean
, that sets the value ofPointerEvent
.
The
PointerEventInit
dictionary also accepts fields from theMouseEvent
,UIEventInit
andEventInit
dictionaries.
Example
JavaScript
Copy Code
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 | Status | Comment |
---|---|---|
Pointer Events – Level 2 The definition of 'PointerEvent' in that specification. |
Editor's Draft | Non-stable version. |
Pointer Events The definition of 'PointerEvent' in that specification. |
Recommendation | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | Not supported[2] | (Yes) [1] | 10ms 11 |
Not supported | Not supported |
Feature | Android | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | Not supported | Not supported | Not supported | Not supported | Not supported | 10 | Not supported | Not supported |
[1] This feature is currently hidden behind a flag — to enable it and experiment, go to about:config and enable dom.w3c_pointer_events.enabled.
[2] In development, see: crbug.com/196799.
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/pointerevent/pointerevent