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

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The InputEvent() constructor creates a new InputEvent.

Syntax

 event = new InputEvent(typeArg, inputEventInit);

Values

typeArg
Is a DOMString representing the name of the event.
inputEventInitOptional

Is a InputEventInit dictionary, having the following fields:

  • inputType: (Optional) A string specifying the type of change for editible content such as, for example, inserting, deleting, or formatting text.
  • data: (Optional) A string containing characters to insert. This may be an empty string if the change doesn't insert text (such as when deleting characters, for example).
  • dataTransfer: (Optional) A DataTransfer object containing information about richtext or plaintext data being added to or removed from editible content.
  • isComposing: (Optional) A boolean indicating that the event is part of a composition session, meaning it is after a compositionstart event but before a compositionend event.  The default is false.
  • ranges: (Optional) An array of static ranges that will be affected by a change to the DOM if the input event is not canceled. 

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
Experimental
Chrome Full support 60Edge ? Firefox Full support 31IE No support NoOpera Full support 47Safari ? WebView Android Full support 60Chrome Android Full support 60Edge Mobile ? Firefox Android Full support 31Opera Android Full support 47Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See also

  • InputEvent, the interface of the objects it constructs.

文档标签和贡献者

此页面的贡献者: sideshowbarker, vishal-wadhwa, fscholz, jpmedley, teoli
最后编辑者: sideshowbarker,