ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

keypress event not launched #379

Closed avsgi09 closed 8 years ago

avsgi09 commented 8 years ago

I have a textbox declared as an InputElement, and I want to know when the user presses the ENTER key, so I have this:

@UiField InputElement searchBox;

private void initDeferred() {
        // Keyup event
        $(searchBox).keyup(new Function() {
            @Override
            public boolean f(final Event e) {
                if (null != e) {
                    GWT.Log("keyup " + e.getCharCode());
                    if (e.getCharCode() == KeyCodes.KEY_ENTER) {
                        doGenericSearch(searchBox.getValue().trim());
                    } else if (e.getCharCode() == KeyCodes.KEY_ESCAPE) {
                        searchBox.setValue("");
                    }
                }
                return true;
            }
        });
   }

But with this code the keyup event launches with a char code of "0". If I add other handlers to the keypress and keydown events I see that only the keypress event gets the 13 char code.

Shouldn't allways (in the three event handlers: keydown, keypress and keyup) be received the 13 char code?

Edit: I see that I must get the getKeyCode() value instead the getCharCode()