It looks like KeyTyped cannot detect keys that don't have a visual representation. I assume this includes backspace.
Java KeyListener: Is the "Backspace" key pressed in KeyTyped
-
30-03-2022 - |
Question
How do I tell if the user pressed the "Backspace" key from inside of the KeyTyped method? They value from arg0.getKeyChar()
is not KeyEvent.CHAR_UNDEFINED
, and arg0.getKeyCode()
is KeyEvent.VK_UNDEFINED
as it always will be inside of the KeyTyped method. Do I have to use the KeyReleased/KeyPressed methods and flag a boolean? Which method fires first? KeyReleased or KeyTyped?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow