Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

KeyEvent - Keypress  RSS feed

 
arun iyer
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I used a keylistener in my piano applet. the problem is that when the user keeps and key pressed, the event gets fired again and again. Is there any way, by which I can stop that...
For example: if the user has pressed q and has not released the key..... he should get only one q and not qqqqqqqqqqqq........
i.e. the event should get fired only once irrespective of the time the user has pressed the key without releasing it.

Expecting help in this regard......
Arun Iyer
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arun,
Post the part of your code that implements KeyListener
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun,
The following code is crude but will do the job you want.

Enjoy,
Manfred.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!