Keyd
The first thing I do after any fresh install is to install keyd. It’s fast, works at the OS-level, and has an example/preset that maps CapsLock to both Ctrl and Esc (Where God intended them to be1 2 3 4 5 6 7) AND includes a vim arrow key layer. I think it’s just about perfect! This utility is the primary reason I spend all my time on my Thinkpad and rarely ever pick up the Macbook anymore (Unless you count installing Asahi). Also, keyd is available from the package manager in both Gentoo and Fedora thanks to GURU and COPR, respectively.
Image Source: https://vintagecomputer.ca/lear-siegler-adm-3a-terminal/
On Gentoo, you will need to install eselect-repository first, and then enable the GURU repository:
root # emerge -a eselect-repository
root # eselect repository enable guru
root # emerge --sync guru
Then you should be able to find keyd with emerge -s keyd, although the package is likely masked. Once you unmask the package, you can then emerge it.
$ echo "app-misc/keyd ~amd64" | sudo tee /etc/portage/package.accept/keyd
$ sudo emerge -a app-misc/keyd
Keyd’s documentation assumes a system running Systemd. On OpenRC, enable the keyd service with:
root # rc-service keyd start
If you need to restart keyd (for example, after editing the config file, located at /etc/keyd/default.conf), simply restart the daemon.
root # rc-service keyd restart
The Gentoo wiki has a page on this (of course).
Remap Capslock to Ctrl/Esc
If you’re on macOS or Windows and are interested in putting the control/escape key(s) where God intended them, you’re in luck! Although it will take a little more work than what is shown here if you want Vim arrow keys as well.
macOS
This article is what I used to guide me. You’ll need to install Karabiner-Elements and create a complex modification. I ended up also needing to create a “default” profile because this configuration would mess with the keymap on my Ferris Sweep when I am at my desk/dock.
Windows
The original blog post I followed is here and it even worked on my work laptop! This works in two steps: One to swap CapsLock and Ctrl, and another to map Ctrl to Esc when tapped rather than held.
Basically, run the following in Powershell as administrator:
$hexified = "00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00".Split(',') | % { };
$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified);
Then install AHK and run this script:
;; based on https://github.com/fenwar/ahk-caps-ctrl-esc/blob/master/AutoHotkey.ahk
;; modified because I already map capslock to ctrl using windows registry
;; here I'm ONLY adding behaviour that LControl tap results in esc
*LControl::
Send {Blind}{LControl down}
return
*LControl up::
Send {Blind}{LControl Up}
;; send Esc only when it was LControl by itself
if A_PRIORKEY = LControl
{
Send {Esc}
}
Return
There you have it! Happy typing to you all :-)
Footnotes
-
https://archive.nytimes.com/www.nytimes.com/library/tech/99/08/circuits/articles/19lett.html ↩
-
https://lowendmac.com/2009/ibm-model-f-a-great-old-keyboard-with-an-outdated-layout/ ↩
-
https://redlib.catsarch.com/r/MechanicalKeyboards/comments/1u70ok/where_god_intended/ ↩
-
https://www.cnn.com/TECH/computing/9909/13/happy.hack.idg/index.html ↩