• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Key event

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic