- Send Escape if you tap Caps Lock alone.
- Send Control if you press Caps Lock with another key.
For both Vim and Emacs world.
Install XCAPE (xcape
). (Linux utility to configure modifier keys to act as other keys when pressed and released on their own.)
Ubuntu:
sudo apt-get install xcape
# make CapsLock behave like Ctrl:
setxkbmap -option ctrl:nocaps
# make short-pressed Ctrl behave like Escape:
xcape -e 'Control_L=Escape'
The effect should apply immediately.
Append code from Step 2 to file ~/.xprofile
to run the command when X starts.
- Download and install Karabiner-Elements, a powerful and stable keyboard customizer.
- Open Karabiner-Elements, select Complex Modifications tab, and click Add rule at the bottom.
- Find Post escape if caps is pressed alone, left_ctrl otherwise and click on enable.
The effect should apply immediately.
- Download and install AutoHotKey.
- Use the script CapsLockCtrlEscape.ahk.
Download and run dual-key-remap. (Note that in config.txt, CONTROL might needed to changed to LEFT_CTRL for some computers)
For both options, the effect should apply immediately.