How to catch an event with a keystroke using UIBinder

In GWT + UiBinder, you can catch clicks as follows:

@UiHandler("cancelButton")
void onCancelButtonClicked(ClickEvent e) {
    // cancel code goes here;
}

Is there an equivalent to keystroke? For example, if the user presses the ESC key, we cancel the action.

Thank you very much.

+3
source share
1 answer

This should work:

@UiHandler("myWidget")
void onKeyDown(KeyDownEvent e) {
  // key down code goes here
}

The widget will have to implement HasKeyDownHandlers.

+5
source

Source: https://habr.com/ru/post/1732586/


All Articles