Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法在我的 JavaFx 应用程序中使用 WINDOWS、Esc 的键盘事件
if (keyEvent.getCode() == KeyCode.WINDOWS) { System.out.print("\n\n window"); keyEvent.consume(); }
我想可能是你使用了错误的 EventHandler。试试这个事件过滤器处理程序,它可以与 consume() 方法一起正常工作。
txtBox.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if(event.getCode()==KeyCode.ESCAPE) event.consume(); }});