title: KeyPressed event in java
body: <p>I have just created a java tic-tac-toe game i would like to figure out how to run a method once the enter key is pressed during a certain condition an example is below...</p>
  
  <pre><code>if(/*condition is met*/){
       //keyListener
  }
  </code></pre>