这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

InputEvent() 构造函数创建新 InputEvent .

句法

 event = new InputEvent(typeArg, inputEventInit);
					

typeArg
DOMString 表示事件的名称。
inputEventInit 可选

InputEventInit 字典,拥有以下字段:

  • 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.

InputEventInit 字典还接受字段来自 UIEventInit 和来自 EventInit 字典。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
InputEvent() 构造函数 Chrome 60 Edge 79 Firefox 31 IE No Opera 47 Safari ? WebView Android 60 Chrome Android 60 Firefox Android 31 Opera Android 44 Safari iOS ? Samsung Internet Android 8.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改: