PointerEvent.PointerEvent()

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 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 PointerEventInit dictionary also accepts fields from the MouseEvent, UIEventInit and EventInit 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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 55Edge Full support 12Firefox Full support 59
Full support 59
Full support 41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE Full support 11
Full support 11
Partial support 10
Prefixed Notes
Prefixed Implemented with the vendor prefix: MS
Notes See MSDN Pointer events updates.
Opera Full support 42Safari No support NoWebView Android Full support 55Chrome Android Full support 55Edge Mobile Full support 12Firefox Android No support No
No support No
Full support 41
Disabled
Disabled From version 41: this feature is behind the dom.w3c_pointer_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android Full support 42Safari iOS No support NoSamsung Internet Android Full support 6.0

Legend

Full support  
Full support
No support  
No 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.

Document Tags and Contributors

Last updated by: sideshowbarker,