Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I know I can do:

bindkey "...." action

where .... is what i get by typing ctrl-v and then ctrl-f1. but it looks bad, contains bad characters (^[), and is generally not cool.

when binding to f1, i can do:

bindkey -k k1 action

but I can't seem to find termcap capability name for ctrl-functionkey.

Where can I find it?

When I press ctrl-v ctrl-f1 on terminal I get:


these are 4 bytes, not 5:

=$ echo "^[O5P" | hexdump -C
00000000  1b 4f 35 50 0a                                    |.O5P.|
share|improve this question
What do you get when you press ctrl-v f1 and ctrl-v ctrl-f1 (since this depends on what terminal emulator you're using)? What does echo $TERM give you? – Dennis Williamson Nov 12 '09 at 16:26
^[O5P : =$ echo "^[O5P" | hexdump -C 00000000 1b 4f 35 50 0a |.O5P.| – user13185 Nov 12 '09 at 19:06

Unfortunately, screen apparently doesn't understand enough function keys to be able to process Ctrl-F1. At least I have not been able to get bindkey -k FF stuff "pressed Ctrl-F1" to work even after trying to define FF or kf25 using the termcap or terminfo commands in ~/.screenrc. I also tried "kf25" in the bindkey command. In either case, I get a "bindkey: unknown key" message.

Perhaps you or someone else will be able to get farther using the information here.

Otherwise, you can continue to use the ugly, uncool method. For onlookers, it's uncool to use hard-coded escape sequences instead of capability names because it won't be portable to other terminal types.

Capability names:

                    termcap        terminfo        xterm

F1                     k1            kf1           ^[OP

Shift-F1               F3            kf13          ^[O2P

Ctrl-F1                FF            kf25          ^[O5P

Ctrl-Shift-F1          FR            kf37          ^[O6P

Output from tput:

$ tput -Txterm kf25 | hd
00000000  1b 4f 35 50                                       |.O5P|
share|improve this answer
it doesn't fully work, but - how did you found the capability names? is there some command to list them? – user13185 Nov 13 '09 at 5:37
It's not obvious how the capability names map to shifted and ctrl'd keys, it's just some old knowledge rolling around in my memory. However the capability names are documented in man 5 terminfo and man 5 termcap. Some might find this list of function keys for all terminfo entries interesting (output is very long): for i in $(find /lib/terminfo/ -type f -printf "%f\n"); do echo; echo $i; for j in {0..63}; do echo "kf$j $(tput -T$i kf$j|hexdump -e '"" 8/1 "'\''%_c'\'' " "\n"')"; done; done|less – Dennis Williamson Nov 13 '09 at 14:32
"not obvious" - other than kf1 + 12 = kf13 ( + 12 = kf25 ) ( + 12 = kf37 ) where PC keyboards typically have 12 function keys. – Dennis Williamson Nov 13 '09 at 14:36

Your Answer


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