There is such a code, but for some reason, it does not work when you press "("
Although everything works fine on numbers, letters, and even if you take a square bracket, it also works, but along with the square box it also works on the letter under it. What is the problem? How to fix it? Why doesn't the regular bracket work? if the documentation is exactly LEFT_PARENTHESIS intended for opening brackets

myField.setOnKeyPressed((event) -> { if (event.getCode() == KeyCode.LEFT_PARENTHESIS) { System.out.println("Works!"); } }); 

Similarly, the option KeyCode.getKeyCode("(") also does not work

    2 answers 2

    In this handler, you get SHIFT or DIGIT9 .

    You need to catch another event:

     myField.setOnKeyTyped((event) -> { if(keyEvent.getCharacter().equals("(")) { System.out.println(keyEvent); } } 

      Then try 0x0207. If this does not work, then this is a JavaFX bug.

      • And in what form to use? KeyCode.valueOf () does not want to accept this - BogdanBida
      • It is possible like this: int x = 0x0207; - Mike N.
      • But it then accepts only the string, and the comparison takes place with KeyCode objects - BogdanBida
      • Then you can like this: String s = "" + 0x0207; - Mike N.
      • Nope, java.lang.IllegalArgumentException: No enum constant javafx.scene.input.KeyCode.519 - BogdanBida