-
21 Jan 2013 6:23 PM #1
Unanswered: addKeyPressHandler in textfield does not work in chrome
Unanswered: addKeyPressHandler in textfield does not work in chrome
i have added an addKeyPressHandler in textfield,but it doest not work in chrome while in IE9 it works fine.
is there any problem in my code like this:
Code:usernameField.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if(event.getNativeEvent().getCharCode()+=KeyCodes.KEY_ENTER) { pwdField.focus(); } } });
-
21 Jan 2013 6:52 PM #2
It doesn't seem to be legal Java:
Assuming that is supposed to be '==' instead, you might be running into cross browser keydown vs keypress issues. Here's a post discussing this on SO: http://stackoverflow.com/questions/9...king-in-chromeCode:if(event.getNativeEvent().getCharCode()+=KeyCodes.KEY_ENTER)
From http://www.quirksmode.org/dom/events/keys.html it is suggested the IE is wrong here, not Chrome:
So try listening to keyup events instead.Special keys
When the user presses special keys such as the arrow keys, the browser should NOT fire keypress events.



Reply With Quote