title: handle multiple key presses ignoring repeated key
body: <p>I had asked this in the comments section of another question (> <a href="https://stackoverflow.com/questions/752999/how-do-i-handle-multiple-key-press-in-java/753078#comment15702382_753078">How do I handle simultaneous key presses in Java?</a>), and was asked to make a new question altogether.</p>
  
  <p>My problem is that when I create an ArrayList of keypresses they are not removed fast enough via the keyReleased event if the user holds down the keys.  I want movement to be with "asdf" and North, East, South, West, NorthEast... etc.</p>
  
  <p>Here is my code for both events:</p>
  
  <pre><code>@Override
  public void keyPressed(KeyEvent e) {
      if(chatTextField.isFocusOwner() == true){
          //do nothing - don't walk
      } else {
          logger.debug("Key Pressed: " + e.getKeyChar());
          lastKey = keysPressed.get(keysPressed.size()-1);
  
          for (String key : keysPressed){
              if (!key.contains(String.valueOf(e.getKeyChar())) &amp;&amp; !lastKey.contains(String.valueOf(e.getKeyChar()))){
                  keysPressed.add(String.valueOf(e.getKeyChar()));
                  System.out.println("ADDED: " + keysPressed);
              }
          }
  
          String keysList = keysPressed.toString();
          if (keysList.contains("w")){
              if (keysList.contains("d")){
                  requestCharacterMove("NorthEast");
              } else if(keysList.contains("a")){
                  requestCharacterMove("NorthWest");
              } else{
                  requestCharacterMove("North");
              }
          } else if (keysList.contains("s")){
              if (keysList.contains("d")){
                  requestCharacterMove("SouthEast");
              } else if(keysList.contains("a")){
                  requestCharacterMove("SouthWest");
              } else{
                  requestCharacterMove("South");
              }
          } else if (keysList.contains("d")){
              requestCharacterMove("East");
          } else if (keysList.contains("a")){
              requestCharacterMove("West");
          }
      }
  }
  
  @Override
  public void keyReleased(KeyEvent e) {
      if(chatTextField.isFocusOwner() == true){
          //do nothing - don't walk
      } else {
          logger.debug("Key Released: " + e.getKeyChar());
          for (String key : keysPressed){
              if (key.contains(String.valueOf(e.getKeyChar()))){
                  keysPressed.remove(String.valueOf(e.getKeyChar()));
                  System.out.println("REMOVED: " + keysPressed);
              }
          }
      }
  }
  
  @Override
  public void keyTyped(KeyEvent arg0) {
      // TODO Auto-generated method stub
  
  }
  </code></pre>
  
  <p>Until I added the second check in there via the lastKey(String) variable the pyramid created was enormous.  Even with that second check the list grows and almost always has two-three duplicates.  Any help on this would be great as my character is moving awkwardly. :(</p>
  
  <p>Also any way to remove duplicate conversions to char, string, arrayList would be great as I'm nervous I used too many types for something "simple".</p>