From 4b3c97aa20490fcf55ab81a101110f3b620c2887 Mon Sep 17 00:00:00 2001 From: Asocia Date: Tue, 30 Nov 2021 22:50:11 +0300 Subject: [PATCH] TIL: Turning off capslock when esc is pressed --- ...urning-off-capslock-when-esc-is-pressed.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 system/turning-off-capslock-when-esc-is-pressed.md diff --git a/system/turning-off-capslock-when-esc-is-pressed.md b/system/turning-off-capslock-when-esc-is-pressed.md new file mode 100644 index 0000000..07a6286 --- /dev/null +++ b/system/turning-off-capslock-when-esc-is-pressed.md @@ -0,0 +1,27 @@ +When my Ctrl key broken, I remapped Capslock to Ctrl as it was the most useless key on the keyboard. Its position was great and suddenly all the shortcuts involving Ctrl become much more easier. Then I forget about Capslock and map it to Ctrl even if both keys are functioning. Recently I made some custom keyboards for myself and I thought maybe I can bring back Capslock. Currently, my right shift key acts as Capslock if tapped once or Shift if being hold. This is great + +I am a vim user and I don't use Capslock other than typing some constant variable names or SQL syntax etc. They are all happening in vim, specifically, in insert mode. Whenever I switch to normal mode, I want my Capslock to be off. I sometimes forget and instead of moving down with `j`, I find myself `J`oining lines. This happened more than 3 times so it is time to do something. + +I could solve this problem in keyboard level because I have a programmable keyboard. I didn't want to this because sometimes I use my laptop's keyboard and I don't want them to behave differently. So I solved it on OS level. Here are the commands that I run in order to achieve this effect: +``` +mkdir -p ~/.xkb/keymap/ +mkdir -p ~/.xkb/symbols/ +vim ~/.xkb/symbols/mysymbols + +partial modifier_keys +xkb_symbols "esc_breaks_caps" { + key { + type = "ALPHABETIC", + actions [Group1] = [ + SetMods(modifiers=none), + SetMods(modifiers=Lock,clearLocks) + ] + }; +}; + +setxkbmap -print > ~/.xkb/keymap/mykbd +vim ~/.xkb/keymap/mykbd +# and add +mysymbols(esc_breaks_caps) to xkb_symbols + +xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY +```