How to catch key-pressed event with UIBinder
Question
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.
Solution
This should work:
@UiHandler("myWidget")
void onKeyDown(KeyDownEvent e) {
// key down code goes here
}
The widget will have to implement HasKeyDownHandlers
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow