Justin Justin - 5 months ago 17
Java Question

Java KeyListener: KeyTyped Backspace, Esc as input

Inside the

KeyTyped
method, how do I tell if Backspace or Esc is being pressed?

Answer

http://www.fileformat.info/info/unicode/char/8/index.htm

When arg0.getKeyChar() is cast to an int: (int)arg0.getKeyChar(), The backspace key comes up with the value 8, and the Esc key comes up with the value 27.