Linux Keyboard – How to Swap Keys in a Virtual Terminal

keyboardkeyboard shortcutslinux

Note: I asked this question in superuser about a month ago, but there hasn't been a reply till then, and the question relates to linux, so I'm posting it here.

I want to swap esc and caps_lock keys on my keyboard. setxkbmap -option caps:swapescape gets the job done but only for X. The keys behave in original way on a virtual console. How can I make them behave in the required way on a vc?

Best Answer

Use loadkeys.

To swap Esc and Caps Lock in the console, run

printf 'keycode 1 = Caps_Lock Caps_Lock\nkeycode 58 = Escape Escape\n' | sudo loadkeys -
Related Question