Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Key event  RSS feed

 
Benjamin FAIVRE
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!
I need some help
I want to detect which keyS are pressed by the user (this takes place in a applet).
I mean, for exemple, to detect when the user has pressed the "ctrl+insert" keys.
I know how to detect when ONE key is pressed, but I don't know how to detect severals keys down.
Any idea?
Thanks!
Benjamin
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Benjamin
I can use some example to illustrate how to do.
Firstly,the KeyEvent.VK_AMPERSAND will return the integer when the key is press.So you can use the timer check that if that key is press equal the other one key is pressed,if the time equal it can invoke the event
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To check for "control keys" being down, use the methods isControlDown(), isAltDown(), isShiftDown(), etc. These methods are on the InputEvent class, and KeyEvent inherits them.

The keyPressed() method your listener for "ctrl+insert" would look something like this :

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!