I'm using Netbeans' bean form to create my GUI.
I've added a keyTyped event to a JTextArea and I want to detect if the typed key is a Backspace.
I'm using keyTyped event for other reasons so I cannot just use the keyPressed event.
This is the generated code (and my if check):
private void langArea1KeyTyped(java.awt.event.KeyEvent evt) {
if(evt.getChar()== backspace) //how can I make this check?
}
evt.getKeyCode()
always returns 0 independent of the typed key.
evt.getKeyChar()
simply deletes the last character printed when printed so I can't use System.out.print(evt.getKeyChar())
to detect its value and check for it.
How can I detect if the typed key is Backspace (or Delete)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…