Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Catching F12

 
Sam Benry
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
quick question: how can I find out when the key F12 is pressed? (and of course do something when it is pressed?)
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that this is AWT or Swing code, you'd add a KeyListener and trigger on KeyEvent.VK_F12 in one of its methods.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you can catch it in a command line application. Rather than the application catching it, the shell or command window will catch it, and not pass it to the app.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic