javascriptunicodelocalizationdom-eventsime

Detecting IME input before enter pressed in Javascript


I'm not even sure if this is possible, so apologies if it's a stupid question.

I've set up an keyup callback through jQuery to run a function when a user types in an input box. It works fine for English.

However when inputting text in Japanese/Korean/Chinese, the function isn't called until the user confirms their text.

Is it possible to detect that they've started typing, and access their as-yet unfinished text?

I'm thinking maybe it's an OS-level thing so Javascript doesn't have access to it.

Edit: I just realised that this works in Chrome and Safari, but not in Firefox (not had a chance to try it on Windows yet). So Chrome calls keyup and it's possible to get the text. But I'm still having the above problem in Firefox.


Solution

  • This is a known issue in Firefox, and what browsers should be doing isn't clear.

    A possible method for working around this problem is demonstrated here, where the text field is polled for changes to the text (rather than relying on events).