Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Key Listeners  RSS feed

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!