I use i3wm, and to map cap lock to escape, I run:
setxkbmap -option caps:swapescape
This works fine, but sometimes while hitting the F1 key, my pinky can accidentally hit the Escape key, which turns on CapsLock.
Gnome has a very nice way to do this, where Shift + Escape = CapsLock. Hitting Escape on its own will do nothing.
I don’t use that so I’m mostly shooting in the dark, but… does
caps:escape_shifted_capslock
do what you want?(source:
localectl list-x11-keymap-options | grep esc
)