This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 41057
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: 19649

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
It is sorta covered in the JavaRanch Style Guide.
subject: Catching F12
Similar Threads
Problems interrupting a thread
Show all/Jump to method in IntelliJ
Sending a "Function Key" Message in JS
Firefox problem