The key codes for Caps Lock, Shift, Left Control and FN key

keyboardtmuxvim

Can somebody please provide the key codes for these keys:

  • Caps Lock
  • Left Shift
  • Left Control
  • Option key
  • FN

The key code I'm talking about is something along the lines of \<Esc>[200~, although I have no idea what that outputs. 😛

Thanks! I need this for remapping some keys in Vim, tmux etc.

Best Answer

These keys are not sent to terminals. Only printable characters, function keys, and combinations of these keys with modifiers are sent to terminal applications (most function keys are sent in the form of escape sequences beginning with ESC [). Modifier keys (like CapsLock, Shift, etc.) are visible to GUI applications, but not to terminal applications. You won't be able to detect a press of these keys in vim or tmux. See What is bash's meta key? for more background.

With the Fn on many laptops, it's even worse: this key is handled by the BIOS and not even visible to the operating system.

Related Question