posted on 2013-11-24 19:18:44
For easier keyboard handling (and to save my fingers) I tend to switch Capslock and right CTRL, as well as left CTRL and left ALT/ALT Gr. For Windows there exist external programs like AutoHotkey and others, but I prefer doing it more low-level through the Windows Registry.
To do this, a key has to be set at
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout. To check if it exists (or look up its current setting),
regedit, and navigate there. (This is just
regedit in Windows Run Dialogue.) Note that the key is named Keyboard Layout, not Keyboard Layouts, do not change the latter.
If there is nothing present, do not worry. First a look on the theory and how the key is structured. Easiest to use are .reg files, a working example may look like this:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,05,00,00,00,1d,00,3a,00,3a,00,1d,00,38,e0,1d,e0,1d,e0,38,e0,00,00,00,00
This switches right CTRL with right ALT and left CTRL with CapsLock.
Looks complicated? This text here can actually be pasted into an empty .txt file. Rename it then to my_keymap.reg (Change the extension so Windows realizes to process this as a registry file.) and double click. Approve the changes, reboot, and you have a sticking change of your keymap. (To undo, delete the registry key and reboot.)
For easier explaining, the same code again, but with some formatting applied, and line numbers added:
1 Windows Registry Editor Version 5.00 2 3 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] 4 "Scancode Map"=hex: 5 6 00,00,00,00, 7 00,00,00,00, 8 9 05,00,00,00, 10 11 1d,00,3a,00, 12 3a,00,1d,00, 13 38,e0,1d,e0, 14 1d,e0,38,e0, 15 16 00,00,00,00
This looks a bit better. But what do these hex-combos mean?
DWORDS (Windows data type representing a 32bit unsigned int) in lines 6, 7 and 16 are ALWAYS zeroes. The last one is a null terminator, the first ones are version information and flags as a header. Header information is always zeroes in the current version of the Scan Code Mapper.
Line 9 is a counter of all the DWORDs representing remappings that follow (Lines 11 to 14 are four mappings) plus the terminator in line 16. That is why there is a
5. This depends on how many mappings you create and has to be set accordingly. For comparison in an example without a single remapping, it should be set to
1 and will then look like this:
1 Windows Registry Editor Version 5.00 2 3 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] 4 "Scancode Map"=hex: 5 6 00,00,00,00, 7 00,00,00,00, 8 9 01,00,00,00, 10 11 00,00,00,00
But no need to create a reg-key like this if you want to have the changes removed again, just delete the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout key and reboot.
These lines from the former example:
11 1d,00,3a,00, 12 3a,00,1d,00, 13 38,e0,1d,e0, 14 1d,e0,38,e0,
are where actually keys are remapped. The first two bytes represent the key's keycode that will be used, the last two bytes represent the key that is changed.
just means map L-Ctrl (1d) onto Caps-Lock (3a). Line 12 is the same keys, but in reverse, 13 and 14 switches R-Alt and R-Ctrl. (Comes in handy for emacs usage.)
Keycodes were taken from this document here, which I stumbled upon somewhere in the msdn pages. See column 'scan 1 make', the first one of each eight entries, page 16 onwards. Note that i.e. Right Alt is noted as
e0_38, but when used as the first half of the DWORD in line 13 or the second half in line 14, it's bytes are actually switched.
A last example, this one just replaces Capslock with R-Ctrl:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex: 00,00,00,00, 00,00,00,00, 02,00,00,00, 1d,00,3a,00, 00,00,00,00
Last three DWORDS are
02,00,00,00,, since two more lines are following, the actual rebind and finally the null terminator.
If you copy paste this, it will not work. You have to reformat, so that there are no newlines in there:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,01,00,00,00,1d,00,3a,00,00,00,00,00
This code can be pasted to a file named
choose-a-name.reg. Save, double-click, reboot, and your CapsLock key will be gone. If you are interested in the original Microsoft article have based this on, which is from 2001, go here. Also this link helped.
View posts from 2017-05, 2017-04, 2017-03, 2017-02, 2017-01, 2016-12, 2016-11, 2016-10, 2016-09, 2016-08, 2016-07, 2016-06, 2016-05, 2016-04, 2016-03, 2016-02, 2016-01, 2015-12, 2015-11, 2015-10, 2015-09, 2015-08, 2015-07, 2015-06, 2015-05, 2015-04, 2015-03, 2015-02, 2015-01, 2014-12, 2014-11, 2014-10, 2014-09, 2014-08, 2014-07, 2014-06, 2014-05, 2014-04, 2014-03, 2014-01, 2013-12, 2013-11, 2013-10