title: what is the preferred way to java awt keyboard input
body: <p>I seen many conflicting recommendations on the internet including here on how to handle input with awt and swing and several people have worked on my code and its a mess.</p>
  
  <p>options</p>
  
  <ul>
  <li>implement KeyListener or extend KeyAdapter</li>
  <li>^to the application's main class, use an anonymous class, use a private class or use an external input managing class.</li>
  <li>to send the event object to each object that needs to know input, to send an array of keys pressed, or to make every class a listener and add it to the main class. </li>
  </ul>
  
  <p>So I could have</p>
  
  <pre><code>public class Board extends JPanel implements KeyListener{
      public Board(){addKeyListener(this);}}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public Board(){addKeyListener( new KeyListener(){...});}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public class Board extends JPanel {
      private class PrivateListener implements KeyListener{...} 
      public Board(){addKeyListener(new PrivateListener());
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public class PublicListener implements KeyAdapter{...}
  public class Board extends JPanel {
      public Board(){addKeyListener(new PublicListener());
  </code></pre>
  
  <p>or</p>
  
  <pre><code>addKeyListener(this);
  addKeyListener(obj1);
  addKeyListener(obj2);
  </code></pre>
  
  <p>and <code>implements KeyListener</code> can be replaced with <code>extends KeyAdapter</code> but I won't do that because java only allows for one parent class.</p>
  
  <p>then there is which I don't know how this got into my code</p>
  
  <pre><code>private boolean [] keys = new boolean[256];
  public void keyPressed(KeyEvent e) {keys[e.getKeyCode()] = true;}
  public void keyReleased(KeyEvent e) {keys[e.getKeyCode()] = false;}
  public boolean isKeyDown(int k) {return keys[k];}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public void keyPressed(KeyEvent e) {
      obj1.keyPressed(e);
      obj2.keyPressed(e);
  }
  </code></pre>
  
  <p>Truly, what is the best implementation of awt keyboard input?</p>