In JavaScript, compositionupdate fires when a new character is received during a text composition session controlled by an IME (or similar) — for example while a user enters a Chinese character with Pinyin and the candidate text changes (MDN).
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for compositionupdate. Start with this line.
JavaScript
addEventListener("compositionupdate", fn)
Call
What it does
addEventListener("compositionupdate", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("compositionupdate", …) — no import required.
Library declarations
JavaScript
addEventListener("compositionupdate", fn)
Parameters
Parameter
Description
Event name
Required. "compositionupdate"
Handler prop
Optional. oncompositionupdate
event.locale
Optional. Deprecated · Non-standard — avoid
Return Value
Return Value
Description
*
Fires as an Element event (listener receives the Event object).
JavaScript Examples
Example 1 — Listen and Log data (MDN)
Log the characters generated on each composition update.
compositionstart:
compositionupdate: ni
compositionupdate: 你
compositionend: 你
How It Works
One handler. Log type and data for each event.
Start opens the session. Often with empty or early data.
Update is the middle. Watch candidates change — this page’s focus.
End closes the session. Final commit point for app logic.
Compatibility
Browser Support
Elementcompositionupdate is Baseline Widely available (MDN: since July 2015). Safe to use in modern and older evergreen browsers.
✓ Baseline · Widely available
compositionupdate
Fires as IME candidate / composing text changes during a session.
99%Widely available
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
compositionupdateExcellent
Bottom line: Use compositionupdate for light previews only. Pair with compositionstart / compositionend. Avoid CompositionEvent.locale.
Frequently Asked Questions
It fires when a new character is received during a text composition session controlled by an IME or similar system — for example while a user enters a Chinese character with a Pinyin IME and the candidate text changes (MDN).
No. MDN marks Element compositionupdate as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. (CompositionEvent.locale is separately Deprecated and Non-standard — avoid it.)
A CompositionEvent (inherits from UIEvent). The useful property for most apps is data — the characters generated for this event (often the current candidate string).
compositionstart begins a session, compositionupdate fires as the candidate text changes (often many times), and compositionend fires when the session completes or is canceled.
Switch to a CJK (or other IME) keyboard layout. Shortcuts vary by OS (for example Win + . on Windows for emoji/IME UI, or Option + ` on some macOS setups).
Use event.data for a light preview of composing text if needed, but do not treat it as final. Keep search, autosave, and submit helpers paused until compositionend.