In JavaScript, compositionstart fires when a text composition system such as an Input Method Editor (IME) starts a new composition session (MDN) — for example when a user begins entering a Chinese character with Pinyin.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for compositionstart. Start with this line.
JavaScript
addEventListener("compositionstart", fn)
Call
What it does
addEventListener("compositionstart", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("compositionstart", …) — no import required.
Library declarations
JavaScript
addEventListener("compositionstart", fn)
Parameters
Parameter
Description
Event name
Required. "compositionstart"
Handler prop
Optional. oncompositionstart
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 when composition starts.
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 tracks candidates. May fire many times.
End closes the session. Final committed text is usually in data / the field value.
Compatibility
Browser Support
Elementcompositionstart is Baseline Widely available (MDN: since July 2015). Safe to use in modern and older evergreen browsers.
✓ Baseline · Widely available
compositionstart
Fires when an IME (or similar) starts a new text composition 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
compositionstartExcellent
Bottom line: Use compositionstart to mark composing state; pair with compositionupdate / compositionend. Avoid CompositionEvent.locale.
Frequently Asked Questions
It fires when a text composition system such as an Input Method Editor (IME) starts a new composition session — for example when a user begins entering a Chinese character with a Pinyin IME (MDN).
No. MDN marks Element compositionstart 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.
compositionstart begins a session, compositionupdate fires as the candidate text changes, 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).
Mark your UI as composing: pause live search, avoid treating partial IME text as final, and wait for compositionend (or input with isComposing false) before committing logic.