Java KeyListener no longer triggers keypress event after a letter key is held down
<p>I am having an issue with the KeyListener in Java where when a letter key (e.g. "s" or "a") is held down, the first time I get the key events properly (keyPressed, keyTyped, keyReleased) However the next time I go to press any key (letter or not) on the keyboard I only get a keyReleased event.</p>

<p>It should be noted that holding down an arrow key doesn't cause the key listener to stop working and pressing a letter key doesn't either. Only holding a letter key stops the key listener from working on any key in the future and the keyReleased event never stops working.</p>

<p>I should also note that letter keys don't seem to have the keyPress event repeat whereas holding a directional key causes repeating keyPress events while its held down.</p>

<p>Here is the class I am using to keep track of key states. I have println statements on the key listener events to try and debug.</p>

<p>I've been struggling with this for a while now and would greatly appreciate any help you can give. Thank you.</p>

<pre><code>  public class KeyboardInput implements KeyListener { 

  private static final int KEY_COUNT = 256;   

  private enum KeyState {

    RELEASED, // Not down

    PRESSED,  // Down, but not the first time

    ONCE      // Down for the first time

  }

  // Current state of the keyboard

  private boolean[] currentKeys = null;

  // Polled keyboard state

  private KeyState[] keys = null;

  public KeyboardInput() {

    currentKeys = new boolean[ KEY_COUNT ];

    keys = new KeyState[ KEY_COUNT ];

    for( int i = 0; i &lt; KEY_COUNT; ++i ) {

      keys[ i ] = KeyState.RELEASED;

    }

  }

  public synchronized void poll() {

    for( int i = 0; i &lt; KEY_COUNT; ++i ) {

      // Set the key state 

      if( currentKeys[ i ] ) {

        // If the key is down now, but was not

        // down last frame, set it to ONCE,

        // otherwise, set it to PRESSED

        if( keys[ i ] == KeyState.RELEASED )

          keys[ i ] = KeyState.ONCE;

        else

          keys[ i ] = KeyState.PRESSED;

      } else {

        keys[ i ] = KeyState.RELEASED;

      }

    }

  }

  public boolean keyDown( int keyCode ) {

    return keys[ keyCode ] == KeyState.ONCE ||

           keys[ keyCode ] == KeyState.PRESSED;

  }

  public boolean keyDownOnce( int keyCode ) {

    return keys[ keyCode ] == KeyState.ONCE;

  }

  public synchronized void keyPressed( KeyEvent e ) {
    System.out.println("Press " + e.getKeyChar());
    int keyCode = e.getKeyCode();
    if( keyCode &gt;= 0 &amp;&amp; keyCode &lt; KEY_COUNT ) {
      currentKeys[ keyCode ] = true;
    }
  }

  public synchronized void keyReleased( KeyEvent e ) {
    System.out.println("release " + e.getKeyChar());
    int keyCode = e.getKeyCode();
    if( keyCode &gt;= 0 &amp;&amp; keyCode &lt; KEY_COUNT ) {
      currentKeys[ keyCode ] = false;
    }
  }

  public void keyTyped( KeyEvent e ) {
      System.out.println("type " + e.getKeyChar());
  }
}
</code></pre>