File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Any Key Press with KeyListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Any Key Press with KeyListener" Watch "Any Key Press with KeyListener" New topic

Any Key Press with KeyListener

Keith Spriggs

Joined: Jul 19, 2012
Posts: 18
Hi guys,
I need a bit of help with this one.

What I want to do is report when key has pressed.

The issue is that do have I have to specify all possible keys individually or is there a method or some code that allows me to do this.

I have a method that needs to send back a string to the user.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Here's a link to the tutorial: How to Write a Key Listener.
It is sorta covered in the JavaRanch Style Guide.
subject: Any Key Press with KeyListener
It's not a secret anymore!