If the user types N+J , I want to print NJ .
Attempting to press N and J simultaneously will cause one KeyEvent to arrive after another. One approach is to create an enum Key similar to this one . Using EnumSet , create Set current . As KEY_PRESSED events KEY_PRESSED update current to include the current keys pressed plus a new one; as KEY_RELEASED events, update current to exclude a new one. The current.equals() method will allow you to compare with the predefined key states used in your game. Note that EnumSet instances are immutable, but effectively small for a reasonable number of keys.
source share