The compositionupdate event fires when an IME (Input Method Editor) or other text composition system starts a new composition session. Learn addEventListener vs oncompositionupdate, CompositionEvent.data, how it pairs with compositionupdate / compositionend, and five try-it labs.
01
Kind
Instance event
02
Type
CompositionEvent
03
When
IME text changes
04
Handler
oncompositionupdate
05
Key field
event.data
06
Status
Baseline widely available
Fundamentals
Introduction
Languages such as Chinese, Japanese, and Korean often use an IME. The user types phonetic or stroke hints; the system shows candidates; then a final character (or string) is committed into the field.
That whole flow is a composition session. compositionupdate means the session just began—before candidates settle and before the final character is committed. MDN’s classic example is starting a Chinese character with a Pinyin IME.
💡
Beginner tip
On compositionupdate, mark your UI as composing (pause live search, show a hint). Wait for compositionend before treating text as final.
Concept
Understanding compositionupdate
An instance event that answers: “Did an IME composition session just begin?”
Fires when a new composition session starts.
CompositionEvent — read data (and sometimes locale).
Siblings — compositionupdate, compositionend.
Useful for pausing search, showing “composing…” UI, custom editors.
Baseline Widely available on MDN (since July 2015).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
A CompositionEvent (inherits from UIEvent and Event).
Event properties
Property
Meaning
data
Characters generated by the input method for this event
locale
Locale of the current input method (when available)
Sequence
🔁 Composition Session Flow
compositionstart — the IME session begins.
compositionupdate — candidate / composing text changes (may fire many times).
compositionend — session completes or is canceled; check event.data.
Ordinary Latin typing may never fire these events. They matter most when an IME is active.
Compare
⚖️ Composition vs input / beforeinput
API
Role during IME
composition*
Session lifecycle (start / update / end)
beforeinput
Edit about to apply; isComposing may be true
input
Value changed; may fire during and after composition
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Listen
el.addEventListener("compositionupdate", fn)
Handler property
el.oncompositionupdate = fn
Committed text
event.data
Log full IME flow
Also listen to start + update
MDN status
Baseline Widely available (Jul 2015)
Snapshot
🔍 At a Glance
Four facts to remember about compositionupdate.
Event type
CompositionEvent
data + locale
Means
IME update
Candidate changes
Pair with
start/end
Full session
Baseline
yes
Widely available
Hands-On
Examples Gallery
Examples follow MDN Element: compositionupdate event. To see live IME events, enable an IME (for example macOS Option+`, Windows Win+., or a CJK keyboard).
📚 Getting Started
Log composing text as the IME updates candidates (MDN style).
Example 1 — addEventListener("compositionupdate")
MDN idea: print event.data whenever composing text changes.
generated characters were: ni
generated characters were: ni3
How It Works
Without an active IME, this listener may stay quiet. During composition, event.data usually holds the current composing string and can change many times before compositionend.
Example 2 — oncompositionupdate Property
Same mid-session hook using the handler property.
JavaScript
const field = document.querySelector("input");
field.oncompositionupdate = (event) => {
console.log("composition update:", event.data);
};
// Assigning again replaces the previous oncompositionupdate handler.
compositionstart:
compositionupdate: ni
compositionupdate: ni3
compositionend: 你
How It Works
Start opens the session. Updates (often many) show intermediate text; end commits or cancels. Notice how compositionupdate lines dominate a typical Pinyin session.
Example 4 — Live Composing Preview
Mirror event.data into a status line while the user composes.
2 update(s) — last data: ni3
Session ended after 2 update(s). Value: 你
How It Works
One short Pinyin character can still produce several compositionupdate events. Counting them helps explain why you should not fire expensive work on every update.
Applications
🚀 Common Use Cases
Showing a live preview of composing / candidate text via event.data.
Powering custom rich-text or chat editors that draw IME underlines themselves.
Debugging internationalization by logging every mid-session change.
Avoiding expensive work on every update (debounce until compositionend).
Pairing with compositionstart / compositionend for the full story.
Under the Hood
🔧 How It Works
1
compositionstart fires
IME begins a new composition session on the focused control.
Start
2
compositionupdate fires
Composing / candidate text changes—often many times. Read event.data.
Update
3
User commits or cancels
IME finishes the session.
Decide
4
✓
compositionend fires
Clear composing UI and treat text as finalized for this session.
Important
📝 Notes
MDN: Baseline Widely available (since July 2015).
Not Deprecated, Experimental, or Non-standard — no status banner required.
Related events: compositionstart, compositionend.
Latin-only typing may never fire composition events—test with a real IME.
compositionupdate is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. Exact IME UI and shortcuts still depend on the operating system and language pack.
✓ Baseline · Widely available
Element compositionupdate
Works across modern desktop and mobile browsers during an active IME composition session.
100%Widely available
Google ChromeSupported · Desktop & Android
Full support
Mozilla FirefoxSupported · Desktop & Android
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaSupported · Modern versions
Full support
Internet ExplorerSupported (legacy)
Supported
compositionupdateBaseline
Bottom line: Listen for compositionupdate to read live composing text; pair with start/end for the full IME session.
Wrap Up
Conclusion
compositionupdate is the “composing text changed” signal. Use event.data for previews and debugging, but wait for compositionend before treating text as final.
Assume composition events fire for plain Latin typing
Treat every update as a final commit
Run expensive search/API calls on every update
Confuse composition with the everyday input event
Overwrite oncompositionupdate if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about compositionupdate
Composing text changed—preview only, then wait for end.
5
Core concepts
🌐01
Text changed
mid-session
Event
📄02
CompositionEvent
data + locale
API
🔁03
Between start/end
may fire many times
Order
🔎04
Preview only
not final text
Pattern
🎯05
Baseline
widely available
Compat
❓ 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 is entering a Chinese character with a Pinyin IME and the candidate text changes.
No. MDN marks Element compositionupdate as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
A CompositionEvent (inherits from UIEvent). Useful properties include data (characters generated for this event) and locale (input method locale).
compositionstart begins a session, compositionupdate fires as the candidate text changes (often many times), and compositionend fires when the session completes or is canceled.
On macOS you can often use Option + ` to open an IME panel; on Windows, Win + . opens emoji/IME-related UI. Exact shortcuts depend on OS language settings. You can also switch to a CJK keyboard layout.
Use event.data to show a live preview of composing text if needed, but do not treat it as final. Keep search/autosave paused until compositionend.
Did you know?
MDN’s demo tips for opening IME UI: on macOS try Option+`; on Windows try Win+.. Your OS language settings still control which IMEs are installed.