Search code examples
javakeylistenerbackspace

Java KeyListener: KeyTyped Backspace, Esc as input


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


Solution

  • 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.