Using Internet Explorer on Windows I have an onkeypress
event detecting text entered into a text box. However when entering Chinese characters this event doesn't fire. Has anyone encountered this or have suggestions on working around this?
Google Suggest (autocomplete) polls the input for changes as the events are completely unreliable for Unicode. Browsers used to support mid-IME input events which was very nice for Japanese, but support quickly broke or was dropped.
Last time I check was 2006 though, so retesting is required. Here are my previous notes:
http://web.archive.org/web/20060220125639/http://fnjordy.cus.org.uk/auto/
Including non-resolved bug in Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=286842
Based on this JSFiddle, it seems the keydown
event does not fire as one might expect. I would use the keyup
event (though, you'll still get partially entered characters).
From my experiment, I got:
Basically, Windows and IE are not playing nicely with character input. I would suggest using the change
event if it's possible in your framework.
Depending on the keyboard settings, writing a single Chinese character usually requires typing several keys. For example, 豈 can be written using a 4-key sequence (山一口廿), as you can see here: http://en.wiktionary.org/wiki/%E8%B1%88
You need to use an onchange event in this case (and also for Korean and Japanese!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With