Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If you look at the Terminal->Preferences->Settings->Keyboard pane it displays how some keyboard keys and combinations map to shell strings.

The list seems really strange to me as it's missing a lot of combinations like Shift+F1 and it maps option+F1 and F6 to the same code. Also the codes shown look like ANSI escape sequences but the function key numbers (ones I checked) don't match up.

I'd like to find an explanation for these details and a reference for adding proper codes for missing combinations like Shift+F1. Thanks for your input

share|improve this question
What is Shift-F1 supposed to do? What do you mean by "don't match up"? It's different from another program you're used to? – Daniel Beck Jun 26 '11 at 11:32
@Daniel The ANSI lising here for example states that a code for F6 key is 64 and in the prefs pane it shows up as 17. As far as what it's supposed to do? I want to map the combination in vim to something useful but my terminal isn't reacting to shift-F1 – audio.zoom Jun 26 '11 at 12:17
up vote 3 down vote accepted

The mappings are different because Mac OS X is not a DOS, for which the web site you linked to was apparently written. The specific mappings were inherited from previous Unix/Linux terminal emulators, as is reflected in your options for what kind of terminal emulator you wish to appear:

enter image description here

As you can see for example here, mapping F6 to ^[[17~ is widespread consensus among terminal emulators.

Terminal's Shift-F5 to Shift-F12 is equivalent to the VT220's F13 to F20.

Terminal's Opt-F1 to Opt-F15 is equivalent to the VT220's F6 to F20, i.e. option "shifts" 5 keys to the right.

I assume this mapping is the result of the desire both to be compatible with existing mappings, and to provide as close to a full 20-F-key keyboard as possible with only 12 or 15 F-keys on modern Macs.

If you don't like these particular mappings, it's easy to change them in the settings dialog you already mentioned. Remember that you can map to pretty much arbitrary input (which is actually a pretty nic(h)e way to do Typinator/TextExpander-like keyboard shortcuts in Terminal):

enter image description here

If you prefer editing in a plain-text editor, you can export a Terminal setting via the cog icon, edit it (it's XML), and import it again.

share|improve this answer
Thanks - that's pretty much a piece I was looking for. I'm still unable to map <S-F2> to vim though this page shows that shortcut being mapped, but now I there's a direction to go on. – audio.zoom Jun 26 '11 at 14:26

This is tricky, it's 2015 and there is still no simple answer for Shift-F2, which I need for Byobu on the remote Linux box.

I wrote this config for a Max OS X, which you can import, which enables F1-F10 combinations with Shift, Ctrl and Alt.

To quote the page, here are examples of magic shortcuts you need to add to your if you want Shift-F2 and friends to work:

F1:          \033OP
Shift-F1:    \033[1;2P
Ctrl-F1:     \033[1;5P
Alt-F1:      \033[1;3P
F10:         \033[20~
Shift-F10:   \033[20;2~
Shift-Left:  \033[1;2D
PgUp:        \033[5~
Alt-PgUp:    \033[5;3~
Delete:      \033[3~
share|improve this answer
Thank you, so much! I integrated your key combination with the popular Peppermint profile. All Byobu shortcuts work great now. – Anjan May 7 at 8:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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