I’ve extended a label in GWT and added a clickEvent. Right now I have it successfully detecting if Control or Alt was held during the click on the label, but ideally I want to have it check if spacebar was held down. Is there any way this is possible? Thanks. Current code is below.
public class CategoryLabel extends Label {
public class CategoryLabelHandler implements ClickHandler {
public void onClick(ClickEvent event) {
CategoryLabel cl = (CategoryLabel) event.getSource();
boolean altDown = event.isAltKeyDown();
boolean ctrlDown = event.isControlKeyDown();
doStuff(cl, altDown, ctrlDown); //Etc.
}
}
}
You need the NativeEvent to get the keyCode of it:
Here is a full list of all possible keyCodes: https://developer.mozilla.org/en/DOM/event/UIEvent/KeyEvent