Use Caps Lock as Ctrl or Esc on a hardware keyboard
Turn Caps Lock into Ctrl or Esc in the system keyboard settings, why the app cannot remap Caps Lock itself, and what Ctrl and Esc do in each session type.
On many keyboards Ctrl is in an awkward corner, and some have no Esc key at all. Turning Caps Lock into Ctrl (or Esc) helps with tmux, vim, Emacs and the Ctrl chords in 3270 and 5250 sessions.
Why the app cannot do it
The app does not receive Caps Lock as a key press. Like Shift, Ctrl and Alt on their own, it is left to the system, so Add mapping cannot record it. Change it in the system settings instead. The app then sees the key you chose.
What Ctrl and Esc then do
VT sessions (SSH, Mosh, Telnet):
- Ctrl with a letter sends the control character, so
Ctrl+Breaches tmux as its prefix andCtrl+Cinterrupts a command. Two exceptions:Ctrl+Vpastes, andCtrl+Ccopies when text is selected. - Esc sends the Escape character, for vim and other programs. See What the keyboard sends in a VT session.
3270 and 5250 sessions:
- Esc is Reset: it unlocks the keyboard after an error.
- Ctrl with a number sends a PF key: Ctrl+1 is PF1 and Ctrl+Shift+1 is PF13. Ctrl+R is also Reset. See Send PF1 to PF24 from a keyboard with no function row.