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?

Was it helpful?

Solution

It looks like KeyTyped cannot detect keys that don't have a visual representation. I assume this includes backspace.

KeyListener, keyPressed versus keyTyped

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top