4 ms·
Few people seem to know about Composition Events: https://w3c.github.io/uievents/#events-compositionevents https://w3c.github.io/uievents/#events-compositioneve
by steadicat 9y ago
Few people seem to know about Composition Events: https://w3c.github.io/uievents/#events-compositionevents https://w3c.github.io/uievents/#events-compositionevents
Using those, implementing IME should be relatively easy. The events tell you which partial characters to show, and which completed characters to insert.
- marijn 9y agoUnfortunately, it's not that easy. Composition events are typically controlled by the IME software, which is not part of the browser proper, and tends to be a lot less serious about conforming to standards. The result is that the data in those events often simply doesn't correspond to the actual DOM changes that they caused. On Android, you can't even rely on the fact that compositionstart fires when a composition is started—with some virtual keyboards (which act as IME providers) you routinely get compositionupdate or compositionend before a start event. Listening to these events and using DOM diffing can get you a more or less accurate idea of what happened. But 'relatively easy' does not apply.