Converting CapsLock to Hyper key with XKB

Warning: While doing this, my cat decided to take a walk over my keyboard because I ignored her attempts to gain my attention for sometime. I saved the file not realizing that there were some syntax errors due to the cat walk. Next time I tried to login, my keyboard wouldn’t work. I couldn’t switch to console. The arch linux fall back did not help either. Finally I had to do a clean install of my OS. So please do not ignore your cat and ensure you do not have any syntax errors.


I needed to set a bunch of keyboard shortcuts that will not conflict with other softwares or my window manager. So control key and alt key was out of question. Super key is in an awkward position in the keyboard. Converting capslock to a hyper key seemed like the logical thing to do.

You can achieve this fairly easily with Xmodmap. However it is an outdated method. It also has the disadvantage that any new USB keyboard will completely reset it. For me personally, the complete reset was being triggered by something else too, randomly. After some hair pulling attempts to figure out what, I decided it is time to ditch the xmodmap.


cd /usr/share/X11/xkb/symbols
sudo cp us hyper
sudo nano hyper
    key <CAPS> {[ Hyper_L ]};
    key <HYPR> {[ Hyper_R , Hyper_L	]};
    modifier_map Mod3   { <HYPR> };
 setxkbmap -layout hyper

If there are syntax errors, the commnad will refuse to load the layout - a lesson I learned painfully as stated above.

The Capslock should be converted to Hyper now. You can test it by setting shortcuts to something in your window manager.

localectl --no-convert set-x11-keymap hyper

Related Posts

Arch Linux Sudoers
Dotfile Management - Criteria and Candidates
Alias for updating YADM
Personal Knowledge Base - Criteria and Candidates
Emacs - Adding clipboad.js to HTML exports
© 2019 - 2022 · Home ยท Theme Simpleness Powered by Hugo ·