GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — TextEvent - Web APIs | MDN

TextEvent

Deprecated

Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.

  • See full compatibility
  • Learn more

The TextEvent interface is a legacy UI event interface for reporting changes to text UI elements.

Note: TextEvent events have been superseded by events such as input, beforeinput, keypress, keyup, and keydown.

Instance properties

This interface also inherits properties from its parent UIEvent, and indirectly from Event.

TextEvent.data Read only

Indicates the data associated with the event.

Instance methods

TextEvent.initTextEvent()

Populates the values of this (new) TextEvent with the given parameters.

Events list

The following is a list of all TextEvent events:

  • textinput

Examples

Listen for text input events

You can register a listener for text input events using EventTarget.addEventListener() as follows:

js
element.addEventListener("textInput", (event) => {
  // …
});

Simple logger showing input events

This example listens for a number of events that are fired on an input, including textInput. The event type and the event data are logged, allowing you to see where textInput is emitted relative to the other events such as those generated by key presses.

HTML

html
<input placeholder="Enter some text" name="name" />
<pre id="log"></pre>
#log {
  height: 140px;
  overflow: scroll;
  padding: 0.5rem;
  border: 1px solid black;
}

JavaScript

const logElement = document.querySelector("#log");
function log(text) {
  logElement.innerText = `${logElement.innerText}${text}\n`;
  logElement.scrollTop = logElement.scrollHeight;
}
js
const input = document.querySelector("input");

input.addEventListener("keypress", updateValue);
input.addEventListener("keyup", updateValue);
input.addEventListener("keydown", updateValue);
input.addEventListener("input", updateValue);
input.addEventListener("beforeinput", updateValue);
input.addEventListener("textInput", updateValue);

function updateValue(e) {
  log(`${e.type}: ${e.data}`);
}

Result

Specifications

Specification
UI Events
# legacy-textevent-events

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on Aug 21, 2026 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.