This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Catching F12 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Catching F12" Watch "Catching F12" New topic

Catching F12

Sam Benry
Ranch Hand

Joined: Mar 21, 2008
Posts: 89
quick question: how can I find out when the key F12 is pressed? (and of course do something when it is pressed?)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41621
Assuming that this is AWT or Swing code, you'd add a KeyListener and trigger on KeyEvent.VK_F12 in one of its methods.

Ping & DNS - my free Android networking tools app
Rob Spoor

Joined: Oct 27, 2005
Posts: 19684

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.

How To Ask Questions How To Answer Questions
subject: Catching F12