• Post Reply Bookmark Topic Watch Topic
  • New Topic

Want to catch key stroke events - urgent  RSS feed

 
Issac Abbas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to find out the key pressed events in Java?? I am not talking about awt classes, i want to use them in my stand alone program. Specifically i want to catch the event of pressing Ctrl+C ( which is used to stop the program ) and execute some manipulations before actually shutting down my program. Any help in this regard is highly appreciated.
 
Lars Vegas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
go to google and try the keyword 'GlobalHotkeyManager'. may be it's what you need, but it's with awt. i've no idea how to do it in another way.
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a method called addShutdownHook in java.lang.Runtime. Shutdown hooks are called when the virtual machine is shutting down -- even if the user pressed Control-C.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!