tags:

views:

158

answers:

1

Hello,

In GWT + UiBinder you can catch clicks like this:

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

Is there an equivalent for key pressed? For example if the user presses the ESC key then we cancel an action.

Thank you so much.

+3  A: 

This should work:

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

The widget will have to implement HasKeyDownHandlers.

Jason Hall