The CAPS key can be mapped to an escape key when pressed once, and a super
(mod4) key when used in combination with other keys.
Create the file /usr/share/X11/xkb/symbols/custom_opts with the following:
// Make Caps an additional Escape
hidden partial modifier_keys
xkb_symbols "super_esc" {
key <CAPS> { [ Escape ] };
modifier_map Mod4 { <CAPS> };
};
Edit /usr/share/X11/xkb/rules/evdev and add a new line in the
! option = symbols section:
custom:super_esc = +custom_opts(super_esc)
Edit /usr/share/X11/xkb/rules/evdev.lst and add a new line the ! option
section:
custom:super_esc Make Caps Lock an additional ESC and Mod4
Restart your X session and apply the setting using your DE's keyboard layout options.
Open dconf-editor, and navigate to org.gnome.desktop.input-sources. Add
'custom:super_esc' to the xkb-options list. For example, if you have no
other options set, just use ['custom:super_esc']. If you have other options
set, separate using commas like so: ['compose:ralt', 'custom:super_esc'].
You can also use the gsettings command to do this via commandline.
Edit /etc/default/keyboard and add custom:super_esc to the XKBOPTIONS
variable (comma-separated).
Most laptops have the alt key really close to the windows key, which can result
in accidental keypresses. I like to use the altwin:alt_win xkb option (Alt is
mapped to Win and the usual Alt) to make both keys work as alt.
This has been working for me but I just now realized that escape is always pressed even if i use it in combination with other keys. So for example, if I press
<Caps>e, what will actually happen is<Esc><Super>e. This is also without even releasing the<Caps>key. While still holding the<Caps>key,<Esc>will already be initiated. Do you have the same behavior? Does anyone know how to fix this? Thanks.