Pergunta

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?

Foi útil?

Solução

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

KeyListener, keyPressed versus keyTyped

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top