Comment #16 on issue 118639 by
chip...@gmail.com: keydown and keyup events
At VMware, we have a product (WSX) that allows a user to log in to their
VMs from any modern web browser and interact with the OS. Because of this,
we need to know exactly what keys are pressed in order to map them to
appropriate key codes sent to the VM.
What we do for every other browser is we create an <input type="text"/>,
shut off any auto-complete, focus the field, and listen for key events.
(This ensures a keyboard will pop up on mobile devices, as there's no API
for directly working with mobile keyboards, sadly).
For each key event we get, we intercept, block the default action, and then
do our work to transform and serialize the key code and send to the other
side.
The biggest feature request we have is "Please make this work on Android,"
to which we have to reply, "We can't. Chrome on Android is broken wrt key
events."
I can see the issue where auto-completion may cause some confusion with key
events. However, it's not much different, I don't think, from Safari on
iOS, which we have no problem with. There are two scenarios that come to
mind:
1) Auto-complete is on, and someone auto-completes (or uses voice input, or
something).
In this case, we get a "input" event that has the contents of the paste,
speech-to-text, auto-completion, whatever. We can check for this and do
something intelligent. (Hey, we suddenly have more than one character! The
user probably didn't type that themselves!)
Auto-completed entries and such don't generate keydown/keyup/keypress
events. The individual keys do. So, I type "he" and auto-complete
the "hello". I'll see the first two key events, then see the input event,
and I can be smart about my handling of it all.
2) Auto-complete is turned off for the field.
This is the mode we're in for WSX.
We know we won't auto-complete on iOS, MacOS, whatever. Android, though,
ignores our request to turn off auto-complete, so that's a problem for us.
Assuming, though, that that was changed to behave like every other browser
and platform out there we've tested with, we wouldn't have the concern
about what you do with auto-completed entries. We'd just deal with key
presses, like we get to for every other browser.
This is pretty clearly broken and a major show-stopper for any web-based
product that needs to do anything more advanced than "my text field has
changed" or "submit this form," which, given this bug report and some
research on Stack Overflow and blogs, is certainly affecting webapp
developers out there.
Android's in a great position to be able to become a great platform for the
newer, more advanced interactive mobile webapp market. But not with this
key input behavior.