我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

The TouchEvent() constructor creates a new TouchEvent.

Syntax

 event = new TouchEvent(typeArg, touchEventInit);

Values

typeArg
Is a DOMString representing the name of the event.
touchEventInit Optional
Is a TouchEventInit dictionary, having the following fields:
  • "touches", optional and defaulting to [], of type Touch[], that is a list of objects for every point of contact currently touching the surface.
  • "targetTouches", optional and defaulting to [], of type Touch[], that is a list of objects for every point of contact that is touching the surface and started on the element that is the target of the current event.
  • "changedTouches", optional and defaulting to [], of type Touch[], that is a list of objects for every point of contact which contributed to the event.
  • "ctrlKey", optional and defaulting to false, of type Boolean, that indicates if the ctrl key was simultaneously pressed.
  • "shiftKey", optional and defaulting to false, of type Boolean, that indicates if the shift key was simultaneously pressed.
  • "altKey", optional and defaulting to false, of type Boolean, that indicates if the alt key was simultaneously pressed.
  • "metaKey", optional and defaulting to false, of type Boolean, that indicates if the meta key was simultaneously pressed.

The TouchEventInit dictionary also accepts fields from UIEventInit and from EventInit dictionaries.

Specifications

Specification Status Comment
Touch Events – Level 2
The definition of 'TouchEvent' in that specification.
Draft Added TouchEvent constructor.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support481 ? ? No Yes No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support481481 ? Yes123.2 ?

1. Chrome only supports the following touchEventInit properties: touches, targetTouches, changedTouches.

See also

  • TouchEvent, the interface of the objects it constructs.

文档标签和贡献者

此页面的贡献者: fscholz, nathnolt, jpmedley, mrenty, dtapuska, teoli
最后编辑者: fscholz,