compositionstart event is fired when the composition of a passage of text is prepared (similar to
keydown for a keyboard input, but fires with special characters that require a sequence of keys and other inputs such as speech recognition or word suggestion on mobile).
- DOM L3
- Default Action
- Start a new composition session when a text composition system is enabled.
||Focused element processing the composition.|
||The type of event.|
||Does the event normally bubble?|
||Is it possible to cancel the event?|
||DOMString (string)||The original string being edited, otherwise the empty string. Read only.|
||DOMString (string)||The language code for the composition event, if available; otherwise, the empty string. Read only.|
|Feature||Chrome||Firefox (Gecko)||Internet Explorer||Opera||Safari|
|Basic support||(Yes)||9.0 (9.0)||(Yes)||Not supported||(Yes)|
|Feature||Android||Firefox Mobile (Gecko)||IE Mobile||Opera Mobile||Safari Mobile|
|Basic support||?||9.0 (9.0)||?||?||?|
 The data attribute value is wrong.
 The event was fired in versions of Gecko before 9.0, but didn't have the DOM Level 3 attributes and methods.
Gecko doesn't support the
locale attribute for trusted events yet. However, web developers can set this value via
initCompositionEvent() when creating untrusted events.
According to the DOM Level3 specification,
compositionstart is cancelable; however, Gecko doesn't currently let you cancel them.
Gecko fires this event when IME starts composition, and some platforms don't have an API for canceling composition once it's begun. In addition, Gecko can't know whether a keyboard event will start composition or not until IME actually starts composition. Because of this,
event.preventDefault() doesn't work on
compositionstart events in Gecko.
Gecko's editors (for example,
<div contenteditable/>, and
designMode) start composition after the bubble phase of
compositionstart. So, by the time your
compositionstart handler is called, no contents have not been modified.
 The data value is always empty.