Generally we apply the Key Listener on specific components like text field, password fields, etc. But I would like to generalize this listener behavior to be applicable to all.
Swing was designed to be used with Key Bindings which might do what you want. I would start by checking out Key Bindings. Don't forget to read the Swing tutorial for complete information.
If that doesn't help then see Global Event Listeners for a couple of suggestions.
1.4m articles
1.4m replys
5 comments
57.0k users