Reputation: 9020
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?
Upvotes: 12
Views: 4770
Reputation: 153
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!)
Upvotes: 1
Reputation: 12866
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
Upvotes: 5
Reputation: 9096
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.
Upvotes: 3