This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Key Listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Key Listeners" Watch "Key Listeners" New topic
Author

Key Listeners

Paul Keohan
Ranch Hand

Joined: Mar 15, 2000
Posts: 411
I'm using a KeyListener interface and writing code for the three methods required.
keyPressed()
keyReleased()
keyTyped()
Can someone please explain to me why keyPressed() and keyReleased() seem to the be the only actions understood. The description of keyTyped sounds like when I type a key it should be invoked - but nothing is happening.
Thanks for any help.
Paul
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Paul,
It depends on what source you are using for the KeyListener. The code below works for me under JDK1.2.

If I remember correctly the TextField has some "bug" in it that keyTyped doesn't get called for every keystroke. I think that is because the TextField intercepts the keys and only lets some of them through...
Regards,
Manfred.
Paul Keohan
Ranch Hand

Joined: Mar 15, 2000
Posts: 411
It's actually a TextField I'm using so that probably explains the problem. I've managed to get working what I need to get working anyway.
Thanks a lot.
Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Key Listeners
 
Similar Threads
KeyEvent TAB
Help! About hotkey
problem to listen key board event
jcombobox.getEditor().getItem() empty
keyboard events