• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

KeyAdapter in java

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,

My problem is that i can't realize how to detect multiple key detection

By that i mean that i want to check if i press CTRL AND ALT AND DELETE I want the input to be like that - "CTRL + ALT + DELETE"
And so on , if i keep pressing keys it'll add "+" And the key it pressed.

Thanks in advance.


 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, are you sure KeyAdapter is the right choice? To listen for specific key combinations, an input action with a specific KeyStroke is probably a better idea.

If you still want to do this, then use a set to store the keys that are pressed. In keyPressed you add the key to the set, in keyReleased you remove it again. In between you have all the pressed keys in your set.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whatever method you use, you can probably not catch Ctrl + Alt + Delete - this is a special key combination on PCs that is handled directly by the OS, and for security reasons applications cannot catch this key combination.

To explain why this would be a security hole: Suppose that you press Ctrl + Alt + Delete and an application shows a lock screen that looks exactly like the lock screen of Windows. It then shows a text box to enter your password to unlock the screen. A user enters his/her password, but not to Windows itself, but to the application. The application has now stolen the user's password.
 
Do you want ants? Because that's how you get ants. And a tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic