key code != char code. Different keys have different (key) codes, even if 
they produce the same chars.

You should only have to handle the KeyPress event (so, use a KeyPressHandler 
instead of the deprecated KeyboardListener). Note that you'd have to take 
special care to a few chars too: '0' (because Firefox fires KeyPress events 
even for keys that don't produce chars, such as the "shift" key) and '\t' 
(otherwise you'll prevent tabbing out of the field) at least, maybe '\n' 
too.

I believe it's best to just "sanitize" the value on the ChangeEvent of the 
field (because the user could paste anything it wants into the field, for 
example), but YMMV (the rest of our team, and our client, disagree with me, 
so we're using a KeyPressHandler to filter keys upfront; but you still need 
to "sanitize" the value somewhere –ChangeEvent or getValue– to handle the 
"paste" use case)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to