InputEvent()

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 editable 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 editable 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

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
InputEvent
60
79
31
No
47
10.1
The inputEventInit parameter is not supported. See bug 170416.
60
60
31
44
10.3
The inputEventInit parameter is not supported. See bug 170416.
8.0

See also

  • InputEvent, the interface of the objects it constructs.

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/InputEvent