Mahesh More
Mahesh More

Reputation: 929

Enter key hit event is not getting captured in Firefox

When I ran my app(GWT java) using chrome browser the following code works well

if (event.getUnicodeCharCode() == 13) 

But the same app ran through Firefox browser doesn't give desirable result.

I want to capture the enter event from all browser and do the same processing code.

Upvotes: 0

Views: 259

Answers (2)

Hilbrand Bouwkamp
Hilbrand Bouwkamp

Reputation: 13519

Instead of the char code look at the key code, code associated with the physical key:

if (event.getKeyCode() == KeyCodes.KEY_ENTER)

Upvotes: 1

Thomas Broyer
Thomas Broyer

Reputation: 64561

Firefox does not fire a keypress event for the Enter key, you have to use keydown or keyup instead (but then handle key codes, rather than character codes; fortunately they're the same for the Enter key and the LF character).

Upvotes: 1

Related Questions