The PointerEvent() constructor creates a new synthetic and untrusted PointerEvent object instance.
Syntax
event = new PointerEvent(type, PointerEventInit);
Arguments
- type
- Is a DOMStringrepresenting the name of the event (see PointerEvent event types).
- PointerEventInitOptional
- Is a PointerEventInitdictionary, having the following fields:- pointerId— optional and defaulting to- 0, of type- long, that sets the value of the instance's- PointerEvent.pointerId.
- width— optional and defaulting to- 1, of type- double, that sets the value of the instance's- PointerEvent.width.
- height— optional and defaulting to- 1, of type- double, that sets the value of the instance's- PointerEvent.height.
- pressure— optional and defaulting to- 0, of type- float, that sets the value of the instance's- PointerEvent.pressure.
- tangentialPressure— optional and defaulting to- 0, of type- float, that sets the value of the instance's- PointerEvent.tangentialPressure.
- tiltX— optional and defaulting to- 0, of type- long, that sets the value of the instance's- PointerEvent.tiltX.
- tiltY— optional and defaulting to- 0, of type- long, that sets the value of the instance's- PointerEvent.tiltY.
- twist— optional and defaulting to- 0, of type- long, that sets the value of the instance's- PointerEvent.twist.
- pointerType— optional and defaulting to- "", of type- DOMString, that sets the value of the instance's- PointerEvent.pointerType.
- isPrimary— optional and defaulting to- false, of type- Boolean, that sets the value of the instance's- PointerEvent.isPrimary.
 Note: The PointerEventInitdictionary also accepts fields from theMouseEvent,UIEventInitandEventInitdictionaries.
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
   }); 
Specifications
| Specification | Status | Comment | 
|---|---|---|
| Pointer Events – Level 2 The definition of 'PointerEvent' in that specification. | Working 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 | 55.0 | No support [1] | 10ms 11 | 42 | No support | 
| tangentialPressureandtwist | (Yes) | No support[1][2] | (Yes) | (Yes) | No support | 
| Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android | 
|---|---|---|---|---|---|---|---|
| Basic support | No support | 55.0 | No support[1] | 10 | 42 | No support | 55.0 | 
| tangentialPressureandtwist | No support | (Yes) | No support[1][2] | (Yes) | (Yes) | No support | (Yes) | 
[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] tangentialPressure and twist were implemented in Firefox 54.