Creating alternate shortcut keys for up/down/home/end

I like using emacs-style navigation in the terminal (e.g. Ctrl + N for down, Ctrl +P for up, Ctrl + A for home, Ctrl + E for end), and I want to do something similar for navigation elsewhere. I would like to use CapsLock + N/P/A/E/etc for down/up/home/end in all apps (I previously used the AutoHotkey script at github.com/…/emacs-like-key-bindings-windows to accomplish this in Windows).

I’m currently using KDE Plasma on Wayland, and I haven’t seen anything obvious to do this while poking around settings. Any suggestions? Thank you in advance!

EDIT: I was able to do what I want with evremap. The crux of the config is:


<span style="color:#323232;">[[dual_role]]
</span><span style="color:#323232;">input = "KEY_CAPSLOCK"
</span><span style="color:#323232;">hold = ["KEY_F19"]
</span><span style="color:#323232;">tap = ["KEY_ESC"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_N"]
</span><span style="color:#323232;">output = ["KEY_DOWN"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_P"]
</span><span style="color:#323232;">output = ["KEY_UP"]
</span>

See my reply below for more info.

Shareni,

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.

pinchcramp,
@pinchcramp@lemmy.dbzer0.com avatar

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.

d3Xt3r,

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:


<span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_LEFTCTRL", "KEY_N"]
</span><span style="color:#323232;">output = ["KEY_DOWN"]
</span>

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.

iggames,

Thank you for the suggestions! I’ll dig into these tonight and see what I can get working.

iggames,

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.


<span style="color:#323232;">device_name = "Telink Wireless Receiver"
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[dual_role]]
</span><span style="color:#323232;">input = "KEY_CAPSLOCK"
</span><span style="color:#323232;">hold = ["KEY_F19"]
</span><span style="color:#323232;">tap = ["KEY_ESC"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_N"]
</span><span style="color:#323232;">output = ["KEY_DOWN"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_P"]
</span><span style="color:#323232;">output = ["KEY_UP"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_B"]
</span><span style="color:#323232;">output = ["KEY_LEFT"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_F"]
</span><span style="color:#323232;">output = ["KEY_RIGHT"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_A"]
</span><span style="color:#323232;">output = ["KEY_HOME"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">[[remap]]
</span><span style="color:#323232;">input = ["KEY_F19", "KEY_E"]
</span><span style="color:#323232;">output = ["KEY_END"]
</span>

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


<span style="color:#323232;">$ cat /usr/share/X11/xkb/symbols/inet | grep FK13
</span><span style="color:#323232;">    key    {      [ XF86Tools         ]       };
</span><span style="color:#323232;">    key   {       [ XF86MailForward       ]       };
</span><span style="color:#323232;">    key   {       [ XF86Word              ]       };      // F2
</span><span style="color:#323232;">    key   {       [ XF86MailForward       ]       };      // F3
</span><span style="color:#323232;">
</span><span style="color:#323232;">$ cat /usr/share/X11/xkb/symbols/inet | grep FK20
</span><span style="color:#323232;">    key    {      [ XF86AudioMicMute      ]       };
</span>
lolcatnip,

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.

iggames,

Looks like there’s an open issue (with fairly recent activity) for adding Wayland support: github.com/joshgoebel/keyszer/issues/27

Thanks for the suggestion, I’ll look into this more.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • kavyap
  • DreamBathrooms
  • cisconetworking
  • osvaldo12
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • Youngstown
  • ethstaker
  • rosin
  • slotface
  • mdbf
  • tacticalgear
  • InstantRegret
  • JUstTest
  • Durango
  • tester
  • everett
  • cubers
  • GTA5RPClips
  • khanakhh
  • provamag3
  • modclub
  • Leos
  • normalnudes
  • megavids
  • anitta
  • lostlight
  • All magazines