Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
79
6
3.1
18
2

The DOM beforeinput event fires when the value of an input or textarea element is about to be modified. But in contrast to the Element/input_event event, it does not fire on the select element. The event also applies to elements with HTMLElement.contentEditable enabled, and to any element when Document.designMode is turned on.

60
79
87
10.1
60
10.3

The InputEvent interface represents an event notifying the user of editable content changes.

60
79
31
10.1
60
10.3

The data read-only property of the InputEvent interface returns a string with inserted characters. This may be an empty string if the change doesn't insert text, such as when characters are deleted.

60
79
67
10.1
60
10.3

The dataTransfer read-only property of the InputEvent interface returns a DataTransfer object containing information about richtext or plaintext data being added to or removed from editable content.

60
79
67
10.1
60
10.3

The getTargetRanges() method of the InputEvent interface returns an array of StaticRange objects that will be affected by a change to the DOM if the input event is not canceled.

60
79
87
10.1
60
10.3

The InputEvent() constructor creates a new InputEvent object.

60
79
31
10.1
60
10.3

The inputType read-only property of the InputEvent interface returns the type of change made to editable content. Possible changes include for example inserting, deleting, and formatting text.

60
79
66
10.1
60
10.3
inputType (insertFromPasteAsQuotation)
Experimental

`insertFromPasteAsQuotation` input type

67

The InputEvent.isComposing read-only property returns a boolean value indicating if the event is fired after Element/compositionstartevent and before Element/compositionendevent.

60
79
31
16.4
60
16.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 3 item(s)
Limitation
  • This browser only partially implements this feature
Removed
  • This feature was removed in a later browser version (79)
Implementation note
  • Not supported on `select`, `checkbox`, or `radio` inputs.

Syntax

JAVASCRIPT
addEventListener("input", (event) => { })

oninput = (event) => { }

Use cases

  • Using input (event)

    The input event fires when the value of an <input>, <select>, or <textarea> element has been changed as a direct result of a user action (such as typing in a textbox or checking a checkbox).

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.