F9-F12 are used by Mac OS X, and I don't want to get rid of them, I just want to be able to send F9-F12 occasionally to programs inside terminal (mostly F9/F10).

Some programs like mc support sequence Escape 9 as synonym for F9 etc. but it's not universal.

It there any way to do it?


fn-Cmd-F9 works as F9 in the Terminal.app on my MacBook Pro, running Mountain Lion 10.8.

  • On my MacBook Air running Mavericks, it's fn-Option-Fkey, not fn-Command-Fkey. – Mark Reed May 8 '14 at 1:19
  • On MacBook Pro running Yosemite, fn-Cmd-F9 works; fn-Opt-F9 just inserts tilde. (I'm using it within emacs.) – Chap Jan 9 '15 at 21:28

You can run an AppleScript (e.g. by wrapping it in a Service in Automator with the Run AppleScript action, with no input in Terminal) that executes the following:

tell application "System Events" 
    tell expose preferences to set the properties of the all windows shortcut to {function key:F1}
    key code 101 # press F9
    tell expose preferences to set the properties of the all windows shortcut to {function key:F9}
end tell

This will temporarily assign a different shortcut to what's bound to F9, press F9, and revert the setting. The setting names are the following for the other Expose preferences:

all windows shortcut
application windows shortcut
show desktop shortcut
dashboard shortcut 

The key codes for F9 to F12 are the following:

F9 101
F10 109
F11 103
F12 111

You can assign keyboard shortcuts to services in System Preferences » Keyboard » Keyboard Shortcuts » Services You will need to learn another shortcut (e.g. Command-F9), but at least you can press a key to initiate the action. For shortcuts using F-keys, see the last paragraph in this answer.

You can alternatively configure a hotkey/macro application like Butler to press the escape sequence you get from cat -v when pressing one of the F-keys while you deactivated the shortcuts.

$ cat -v

These are F9 to F12, in order.

In Butler, it looks like this for F9:

enter image description here

I pressed Ctrl-[, [, 2, 0, ~ for that sequence. On my keyboard layout, ~ is Shift-backtick, that's why the Shift modifier is visible. Works anyway.

Configure a shortcut and you can start pressing that to get the escape sequence:

enter image description here

Works in mc, and I don't recall another CLI program with F-keys at the moment. But it's not the mc specific escape sequence, so it will probably work in others.

Alternatively, many command line applications understand Esc, 1 (sequence) to mean F1, through to Esc, 0 meaning F10.

  • Ah, good morning Mrs Sledgehammer! Do allow me the pleasure of introducing you to Mr Nut... – Robino Jun 2 '16 at 8:57

You can disable the keyboard shortcut for F12 under:

keyboard preferences > keyboard shortcuts

  • This wasn't enough by itself for me, but is along the right lines. – Robino Jun 2 '16 at 8:47

I'll add that if you are on a laptop, you're not actually using F9-F12, you're pressing "next song", "audio mute", "volume down" (example from recent macbookpro). To actually press F9-F12, keep 'Fn' pressed while using the same key.

On the desktop, if you have stuff like Exposé, Spaces, and so on mapped to the actual F9-F12 keyboard keys, I find it useful to associate those functions with additional mouse buttons (eg. I use the 'lateral button pair' of the Mighty Mouse to activate Exposé) or screen edges (eg. I have 'screen standby' in top-left) - but this is actually a subjective matter.

  • 1
    Turning this stuff off is the first thing I do on every new Mac. Expose etc. F9 is always F9, never next song. – taw Sep 27 '10 at 14:09

This is the two step process I used to get CoRD (Remote Desktop for Mac):

  1. System Preferences > Keyboard > Keyboard > Check "Use all F1, F2, etc. keys as standard function keys"
  2. System Preferences > Keyboard > Shortcuts > Uncheck "Show Desktop", "Show Dashboard"

The first step is what @taw is talking about in one of the comments; it gets function keys f1-f10 working. The second step stops f11 and f12 key presses from being intercepted by OSX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.