title: Listening to the escape key
body: <p>I want to clear text field when the escape is pressed.</p>
  
  <p>I added KeyListener to the JTextField</p>
  
  <pre><code>bondIDTextField.addKeyListener(new KeyListener() {
  
              @Override
              public void keyTyped(KeyEvent e) {
  
                  if( e.getKeyCode() ==   KeyEvent.VK_ESCAPE)
                      ((JTextField)e.getSource()).setText("");
  
              }
  
              @Override
              public void keyReleased(KeyEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void keyPressed(KeyEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
          });
  </code></pre>