keyd and the Modern Space Cadet
A Modern Space Cadet
Some time ago I read Steve Losh's article A Modern Space Cadet and was sold on it instantly. Having suffered various wrist pains and soreness since I'd been using computers seriously, I was then convinced that I needed to get the PC keyboard working for me instead of me working around it.
At this time I had no real clue about how to solve this issue, so fiddled around
with setxkbmap
and GNOME's keyboard settings and only really achieved turning
caps into ctrl
but the rest of the changes were beyond me.
Enter keyd
:
keyd
keyd
is a system-wide key remapping daemon for Linux. I've been using it
recently and now can't really live without it. I've totally ditched whatever
ad-hoc remapping I've had in place before and completely switched over to
keyd
.
keyd
works (as far as I can tell) everywhere, so doesn't rely on X11/Wayland
running or some desktop environment. Configuration is sensible and (reasonably)
obvious.
Here are the contents of my /etc/keyd/default.conf
file:
[ids] * -046d:406f:cbff713c [main] capslock = overload(control, esc) esc = capslock leftshift = overload(shift, S-9) rightshift = overload(shift, S-0) rightalt = leftalt
Better Control/Escape/Caps Lock
I'd been rebinding Caps Lock to escape since before I even used Vim or Linux for
that matter and well before stumbling across Losh's article. What I could never
accomplish with setxkbmap
et al. however was overloading caps to run a dual
role as both ctrl
and esc
; hence the line
capslock = overload(control, esc)
Of course, the following line restores the use of the Caps Lock to the (IMO hard to reach) escape key:
esc = capslock
Shift Parentheses
Shift Parentheses were a big idea from the Modern Space Cadet I couldn't shake
off after reading and had been grumbling about going without from then on. To
my delight keyd
's overloading handles this without issue:
leftshift = overload(shift, S-9) rightshift = overload(shift, S-0)
This I think is some real magic, and it works exactly as Steve describes. I
thought I'd have to rebind the actual parens on my keyboard with noop
to get
out of an old habit, but after only a few days the shift-parens seem to be
already in my muscle memory.
keyd
Weirdness
keyd
is cool but can exhibit some weirdness. For example, without the line
rightalt = leftalt
I could no longer M-x
in Emacs using the right alt key.
There are probably other examples of this for more involved setups but this was
most glaring to me.
Admittedly though this could also result from my unusual pairing of physical and digital keyboard layout —typing on a UK keyboard with Linux set to a US layout.