I think keyszer would be able to do it, but I don't think it will work with Wayland. My suggestion, if you don't mind spending some money, is to get a nice keyboard with programmable firmware like QMK. I wasn't able to find a comprehensive list but I know Keychron and ZSA sell keyboards that run QMK.
Linux
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Looks like there’s an open issue (with fairly recent activity) for adding Wayland support: https://github.com/joshgoebel/keyszer/issues/27
Thanks for the suggestion, I’ll look into this more.
There are several tools for this which work on Wayland. An easy way to do simple remapping would be evremap, your config would look something like this:
[[remap]]
input = ["KEY_LEFTCTRL", "KEY_N"]
output = ["KEY_DOWN"]
If you want more complex macros, AutoHotkey style, check out hawck. Note that hawck doesn't support GUI automation in case you were curious, but if you want something similar you could pair it with KWin scripts and ydotool.
Thank you for the suggestions! I’ll dig into these tonight and see what I can get working.
Looks like evremap will do what I want, plus a nifty bonus! The following config lets me use CapsLock + N/P/etc to navigate. And if I just tap CapsLock without pressing anything else, it will act as escape.
device_name = "Telink Wireless Receiver"
[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_F19"]
tap = ["KEY_ESC"]
[[remap]]
input = ["KEY_F19", "KEY_N"]
output = ["KEY_DOWN"]
[[remap]]
input = ["KEY_F19", "KEY_P"]
output = ["KEY_UP"]
[[remap]]
input = ["KEY_F19", "KEY_B"]
output = ["KEY_LEFT"]
[[remap]]
input = ["KEY_F19", "KEY_F"]
output = ["KEY_RIGHT"]
[[remap]]
input = ["KEY_F19", "KEY_A"]
output = ["KEY_HOME"]
[[remap]]
input = ["KEY_F19", "KEY_E"]
output = ["KEY_END"]
Note: I used F19 because it doesn't seem to be bound to anything by default. Apparently, a bunch of the other function keys already did things, as described in /usr/share/X11/xkb/symbols/inet
$ cat /usr/share/X11/xkb/symbols/inet | grep FK13
key { [ XF86Tools ] };
key { [ XF86MailForward ] };
key { [ XF86Word ] }; // F2
key { [ XF86MailForward ] }; // F3
$ cat /usr/share/X11/xkb/symbols/inet | grep FK20
key { [ XF86AudioMicMute ] };
I see you already have a solution but someone else might find this interesting: keyd is a pretty powerful keyboard remapping utility that works everywhere (X11, Wayland and VTs). Think QMK but done on the OS.
Check out kmonad. You can set on-hold caps to switch to an Emacs navigation layer. In that layer you can for example set the n button to send the arrow instead.
It complains in Wayland about using some X11 tool, but works without issues from my limited experience.