keyd provides system-wide keyboard remapping on Linux. The installation commands below are for Debian.

§Installation

1
2
sudo apt install keyd
sudo systemctl enable --now keyd

Debian names the executable keyd.rvaiya because another package already provides a program named keyd. The service is still named keyd.

§Configuration

/etc/keyd/default.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[ids]
*

[main]
# the key btw left-shift and z/y; only there in uk-based layout
102nd = z
z = x
x = c
c = v
v = b
b = backspace

# swap control and command on the Magic Keyboard
leftmeta = leftcontrol
leftcontrol = leftmeta

# right command as enter
rightmeta = enter

# swap left-shift with capslock
capslock = leftshift
leftshift = capslock

ejectcd = delete

# KDE: toggle Konsole terminal (at position in dock)
scale = M-2
f3 = M-2

# voxtype so that doesn't interfere with existing f6 shortcut for other apps
f6 = f13

§Commands

Reload the configuration after editing it:

1
sudo keyd.rvaiya reload

Print key events and device IDs for identifying key names:

1
sudo keyd.rvaiya monitor

Check whether the daemon is running:

1
sudo systemctl status keyd

Show keyd logs and configuration errors:

1
sudo journalctl -eu keyd

If a bad mapping makes the keyboard unusable, Backspace+Escape+Enter terminates keyd.