Byobu passes the key combination through, htop interprets it as F4, and enables filtering. Gnome Terminal passes the inputs separately, mc interprets them as F10, and mc exits.Įxample with Alt: I want to press F4 to filter htop, but byobu intercepts F4 and interprets it as "next window". They are also useful with a physical keyboard when your terminal program or another program running in the same session (eg byobu/screen/tmux) intercepts F-keys for its own purposes.Įxample with Esc: I want to press F10 to quit mc, the Midnight Commander, but Gnome Terminal intercepts F10 and interprets it as its menu key. These shortcuts are very helpful when using a terminal emulator on a phone or other restricted device that lacks physical F-keys.
You can often use Esc followed by Number, or Alt+Number to simulate F1- F10, using 0 for F10.
However, if for whatever reason you can't install a new keyboard, there are other alternatives, as long as your terminal app allows you to press Esc and/or Alt. Also, note that you may have a time limit: some applications only recognize escape sequences if they come in fast enough, so that they can give a meaning to the Esc key alone.Īs Drake Clarris suggests, on Android, you can install alternate keyboards, such as Hacker's Keyboard that include F-keys. Since the sequences may be awkward to type, do investigate changing the key bindings in your application or using another terminal emulator. Ctrl+ V inserts the next character (which will be the escape character) literally, and you'll be able to see the rest of the sequence, which consists of ordinary characters.
$ for x in do echo -n "F$x " tput kf$x | cat -A echo doneĪnother way to see the escape sequence for a function key is to press Ctrl+ V in a terminal application that doesn't rebind the Ctrl+ V key (such as the shell). For example, the shell snippet below shows the escape sequences corresponding to each function key. These sequences are stored in the terminfo database. You can use the tput command to see what escape sequence applications expect for each function key on your terminal. Apart from a few common ones that have an associated control character ( Tab is Ctrl+I, Enter is Ctrl+M, Esc is Ctrl+[), function keys send escape sequences, beginning with Ctrl+[ [ or Ctrl+[ O. So al function keys are encoded as sequences of characters, using control characters. Terminals only understand characters, not keys.