The applet below prints information about keystrokes as Swing sees them. [source code]
SwingKeys requires Java 1.4+ and Swing. See JavaKeys for an AWT version that works with Java 1.1+. SwingKeys with JPanel event source is similar to this applet, but gets key events from a JPanel instead of a JTextField.
Swing components may produce different sequences of events depending on whether there are any input method event (IME) listeners present. You may see different events with different settings of the IME checkbox, particularly if you type characters that use dead keys or otherwise involve an input method. Since the simplest and most common use of Swing text components is to let Swing handle the input method, the IME checkbox is off by default. IME behavior is not completely symmetrical; turning the IME checkbox on then off again may not give the same event sequence as when it has never been turned on (this is due to JTextComponent behavior, not a bug in SwingKeys).