The answer above by porkfreezer is great! To make this a permanent solution, you could make a .settings
directory, or use your .local
directory, to create your own keymap file like you were trying to do, that can be used when logging into a TTY. To do this, I recommend copying the keyboard keymap you are currently useing (for me it's us.map.gz
) to your home directory that you chose above, for me this looks like
cp /usr/share/kbd/keymaps/i386/qwerty/us.map.gz ~/.settings/
Then you can unzip and edit that file to contain the key mapping you want. For me I have switched the Escape key and Caps_Lock, for use with vim. Then create a symlink to this file to a directory where Linux can find it, like so:
sudo ln -s ~/.settings/custom.map /usr/share/kbd/keymaps/i386/qwerty/custom.map
Now, when in a TTY, you can run sudo loadkeys custom
to load the key mapping. To have this as the default, you could create a
/etc/vconsole.conf
file containing the line
KEYMAP=custom
Then edit your /etc/mkinitcpio.conf
file (you will need superuser privileges) by adding keymap
to the end of the hooks
list, this should look something like the following
...
HOOKS=(base udev autodetect modconf block filesystems keyboard fsck keymap)
...
Then run
sudo mkinitcpio -p linux
And that's it! After a reboot, whenever you log into a TTY, your custom keymap will be used.
Hopfully this helps!