我正在尝试在没有焦点的窗口小部件时捕获键盘事件。我尝试将其添加到复合小部件中:
addDomHandler(new KeyPressHandler(){
public void onKeyPress(KeyPressEvent event) {
logger.info("onKeyPress: "+event);
}
}, KeyPressEvent.getType());
但我没有捕获键盘事件。我希望能够在Ctrl
事件发生时确定mousedown
键何时被按下。我怎么能这样做?
答案 0 :(得分:1)
使用MouseDownHandler:
MouseDownHandler mouseDownHandler = new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
if (event.isControlKeyDown()) {
// do something
}
}
};
myCompositeWidget.addDomHandler(mouseDownHandler, MouseDownEvent.getType());