Preferred method to re-map modifiers in TTY Console sessions? (i.e. CapLock -> Ctrl)

What’s the current preferred method / best practice to remap CapsLock to Ctrl for TTY Console sessions?

I’m aware how to perform key re-mappings in Gnome with tweaks, but that only applies when in GNOME Desktop Environment and not when using TTY Console sessions.

Thanks in advance!

Here is a way to swap CapsLock and Ctrl swap for virtual consoles:

  1. create /etc/console-setup/ctrlswapcaps.kmap

keymaps 0-127
keycode 29 = Caps_Lock
keycode 58 = Control

  1. edit /etc/vconsole.conf to add the kmap file

KEYMAP_TOGGLE=“/etc/console-setup/ctrlswapcaps.kmap”

For graphical display, instead of configuring each window manager, I just swap the keys in X11 setting so it works for any window manager (not sure if it works with Vulkan-based ones since I use XFCE4):

  • edit or create /etc/X11/xorg.conf.d/00-keyboard.conf (the important part is Option “XkbOptions” “ctrl:swapcaps”)

    Section “InputClass”
    Identifier “system-keyboard”
    MatchIsKeyboard “on”

    Option “XkbOptions” “ctrl:swapcaps”
    EndSection

Which does not work now the defaults are to use wayland.

not sure about best, but keyd is my favorite.

What’s the best way with Wayland to perform it? And that will cover tty console sessions too?

You are correct, my mistake. What I meant was Wayland-based, not Vulkan (I was too focused on gaming on Fedora).

The best way, no matter the cost, is to have the keyboard manufacturers research the actual usage of keys, and re-design the keyboard to be more ergonomical and more customizable, so that keyboards fit the user, not the other way around. Then no more hacking to swap keys, etc.

We can’t have people adapting to machines. Machines should be designed to adapt to users.

While I agree the sentiment. I live in reality and current state of affairs requires adaption by the user as this is not going to change any time soon. Hardware exists and users will use it until it dies so there requires a middle ground; manufacturers adapting, users adapting, and software adapting. All 3 need to coexist to cover the maximum amount of uses cases and ensure full flexibility. As we all know today’s solution may be tomorrow’s problem as we adapt and evolve.