How can I catch an event from the keyboard on an iPhone web app?
This would seem to be easy but there is a big complication I cannot get around. If I use $('input').onkeyup I do indeed get the events, but the problem lies with autocorrection and Japanese kanji input (with the latter a list of suggestions are given of the correct kanji and you cli开发者_Go百科ck that to convert the roman input, however the clicking doesn't catch an $('input').onkeyup, and the focus doesn't change. See here, click the left blue and the form changes to that:
These elements look like they are HTML elements (the 'autocorrect' or 'kanji') but I can't see how to actually get what they are, as they only appear in the simulator, not in Safari proper.
Failing that, is there a simple way to do a 'click anywhere' plus check to see if the 'input' has focus, yet wasn't the place actually clicked?
Haven't tested this myself but I would expect that particular flow to dispatch a "textInput" event, in webkit at least.
http://www.w3.org/TR/DOM-Level-3-Events/#event-type-textInput
Specifically, you would expect this type of event "from the processing of an input method editor" that sounds exactly like your situation. You may need to inspect the extra properties on the event to find out information about the actual input.
Additional information about this event can be found here: http://unixpapa.com/js/key.html
Edit: Note that this event will probably only work with the standard addEventListener approach, not a simple handler attribute setting as you have done with element.onkeyup
Edit: Also worth checking out the "composition" event types listed in the first document I linked as well. There may be some overlap depending upon exactly what event you want to handle.
精彩评论