title: Java - JTextField - Call function when user press "space bar"
body: <p>I made some searches and I didn't find how to call a function when the user press the key "space bar", I have this code:</p>
  
  <pre><code>edtCodigos.addKeyListener(new KeyAdapter() {
      public void keyPressed(KeyEvent e) {
          if (e.getKeyCode() == KeyEvent.VK_SPACE){
              callFunction();
          }
      }
  )};
  </code></pre>
  
  <p>Note: I want to avoid the "space", the key will be used just to call the function</p>
  
  <p>Any ideas how can I do it or code samples will be appreciated ;)</p>