Java KeyListener: KeyTyped Backspace, Esc as input

前端 未结 7 1038
耶瑟儿~
耶瑟儿~ 2020-12-29 10:33

Inside the KeyTyped method, how do I tell if Backspace or Esc is being pressed?

7条回答
  •  长发绾君心
    2020-12-29 11:04

    Check below code, I hope it will work for you.

    @FXML
    public void keyPresses(KeyEvent ke) 
    {
        if (ke.getCode().equals(KeyCode.BACK_SPACE)) {
            System.out.println("It Works Backspace pressed..!");
        }
    }
    

提交回复
热议问题