Adam Oudad

Adam Oudad

(Machine) Learning log.

3 minutes read

If you commonly use keyboard shortcuts to save time clicking and moving the mouse, you may have noticed how many keyboard shortcuts require to press the Control key. Now due to the inconvenient placement of the Control keys, it can be annoying for heavy users who waste time moving hands or even result in musculoskeletal issues. Emacs is infamously tagged with the "Emacs pinky", a repetitive strain injury due to the heavy use of Control key in Emacs for almost any command (even basic commands like moving the cursor are mapped to Control keyboard shortcuts).

So to alleviate these inconvenience, a simple method is to move the control key somewhere else on the keyboard, that is to actually swap it with another key. The trick I am presenting here is to remap the keycodes that the operating system understand to different meanings. The most popular option is, I believe, to swap Left Control key with Caps Lock. The Caps Lock key is closer to the fingers and is usually the target of the ring finger, which has more powerful muscles than the pinky.

Windows 10

On Windows 10, the trick involves changing the registry. Open the registry editor1. Then go to the directory called Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout. Now add a Binary value named Scancode Map with the following values

00 00 00 00
00 00 00 00
03 00 00 00
1d 00 3a 00
3a 00 1d 00
00 00 00 00

The source I am taking this from also provides a powershell script to execute which automatically does the same2. The changes will take effect after rebooting the machine.

Linux

X window system

On any X window system based window manager, such as i3wm, Gnome or KDE, just create a file ~/.Xmodmap with the following content

clear lock
clear control
keycode 66 = Control_L
keycode 37 = Caps_Lock
add control = Control_L Control_R
add lock = Caps_Lock

This change will need a reboot of the machine, or at least a restart of X window.

Wayland

Wayland is a window compositor with the goal to replace X window. For such window managers, changing .Xmodmap file won't have any effect since this file only concers X window. In this case, the trick seems to be specific to the window manager you use. I use Sway as window manager, and swapping Left Control and Caps Lock can be done by adding the following to your ~/.config/sway/config file

input * {
xkb_layout "jp"
xkb_options "ctrl:nocaps,ctrl:swapcaps"
}

In my case the keyboard layout is "jp" so you may have to change this bit to fit your own keyboard layout.

Footnotes

comments powered by Disqus

Recent posts

See more

Categories

About

This website is a weblog were I write about computer science, machine learning, language learning.