Javascript - Detecting chinese character input like Google docs

Pizpaiduardaf

New Member
I'm trying to reliably detect when chinese characters are inserted into a text box. If I add keyup, keydown, and keypress handlers to an input field, no event is fired when the user selects a chinese character from an IME (input method editor). For example, on Mac/Firefox with Chinese simplified pinyan if I type:ni then hit 1I only receive the keydown event for 'n' and the key up for '1'. No keypress event is fired. Note: I'm using GWT but I don't think it should matter.I was curious how Google docs does this. I noticed specifically for Chinese, the 'n' character appended as text to a hidden iframe with the class "docs-texteventtarget-iframe" (but not the 'i'). I would imagine they're doing this to detect when a chinese character is inserted.How does Google docs know that the input language changed to chinese? For instance, if my input language is English and I type 'n', it is not appended to that hidden iframe. Is there any common techniques to detecting chinese character key events?
 
Top