onKeyPress Firefox / IE differences

38 views
Skip to first unread message

Brian Glick

unread,
Aug 21, 2006, 10:05:19 AM8/21/06
to Google Web Toolkit
In case my hours of pain can be of help to someone else, it appears
that the onKeyPress is called differently from IE and Firefox.

In IE, you don't seem to receive events for navigation type keypresses,
like tabbing between fields, but in firefox you do.

In my situation, i was trying to only allow numbers to be typed into a
field and I had the following validation:

public void onKeyPress(Widget sender, char keyCode, int modifiers) {
if(!Character.isDigit(keyCode)) {
cancelKey();
showBadTextIndicator();
}
}

This worked fine in IE and the user could still tab to the next field,
but in order to allow the tab key in Firefox to work, I had to change
the condition to the following

!Character.isDigit(keyCode) || Character.isLetterOrDigit(keyCode)

----
Brian Glick
http://jroller.com/page/hifi78

Slava

unread,
Aug 21, 2006, 12:34:43 PM8/21/06
to Google Web Toolkit
try to use onKeyUp instead

Reply all
Reply to author
Forward
0 new messages