title: How to use KeyEvent in JavaFX project?
body: <p>I have searched for a long time for how to write a <code>KeyEvent</code> to allow my Button clicks by <code>ENTER key</code>. Note that I'm using JavaFX and <code>FXML</code> files. </p>
  
  <p>The problem is that when set in the onKeyTyped text field in the FXML file, the FXML Files doesn't accept it. It says <code>Handle method not found</code>. It just accept <code>ActionEvent</code> method so I have tried this code:</p>
  
  <pre><code> @FXML
   private void key (KeyEvent evt) throws IOException{ 
         if (evt.getCode() == KeyEvent.VK_ENTER){
         String az = text1.getText();
         //c.1
         if(az.contains("1")){ 
            String hh = text11.getText();
            Socket socket = null;
            InetSocketAddress isa = new InetSocketAddress (hh,80);  
         } 
      }
  }
  </code></pre>
  
  <p>So please can anybody help me?</p>