How to remap keys on Windows
How I remapped my Windows key to the ctrl key.
Published — 4 minute read
I’ve been using Windows 11 for the past couple days, and it’s been tough getting re-used to my meta key on my HHKB2 being the Windows key instead of the macOS Command key.
This has made keyboard shortcuts difficult, as my muscle memory presses the meta key and then I get any number of things in my face: the Windows Start Menu, File Explorer, even Teams, which comes with Windows 11 now.
Rather than retrain valuable muscle memory, I remapped the Windows key to act as the ctrl key instead, using the Windows Registry.
Remap keys with the Windows Registry #
This is how I remapped my Windows key to the ctrl key.
Steps:
- Create a new file in your text editor of choice (Sublime, Notepad.exe)
- Add the corresponding code below according to which keys you want to map
- Save the file as a
.reg
file, e.g.win-key-to-ctrl.reg
- Back up your registry (important!) by opening the Registry Editor and choosing File > Export and saving the resulting file
- Open up the
.reg
file you just created - Click Yes on the “Are you sure you want to continue?” warning
- Reboot
Registry codes #
Put one of these in your .reg
file:
Right Windows key to right 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,e0,5c,e0,00,00,00,00
Left Windows to left 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,5b,e0,00,00,00,00
Both Windows keys to both ctrls: #
This is the one I used.
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,03,00,00,00,1d,00,5b,e0,1d,e0,5c,e0,\
00,00,00,00
Reverting changes #
To revert the registry changes back, you have two options:
- Restore the backup you made previously, and reboot
- Delete the Scancode Map registry value
Deleting the Scancode Map registry value #
According to the docs, you can safely delete this registry value if you want to revert the changes you made.
Steps:
- Open Registry Editor by typing
regedit
in the Start Menu or Run - Back up your registry (important!) by opening the Registry Editor and choosing File > Export and saving the resulting file
- Go to
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
(you can put this in the handy dandy address bar they added in 2016) - Delete Scancode Map
- Reboot
Remap keys with third-party software #
There’s a couple of utilities that make it easier to add scancode mappings to the registry:
- SharpKeys (last commit Oct 2021, more well known)
- Scancode Map (last commit Nov 2019)
If you don’t want to mess with the registry, you can also use Microsoft PowerToys, which needs to be running in the background to work. It has some advantages and disadvantages over the registry method.
Using SharpKeys #
You can download SharpKeys from the GitHub releases page or via the Windows Package Manager:
winget install sharpkeys
Steps:
- Back up your registry (important!) by opening the Registry Editor and choosing File > Export and saving the resulting file
- Open SharpKeys
- Add your mapping by clicking the Add button
- Click the Write to Registry button
- Reboot
SharpKeys does have a bug where minimizing the window causes it to freak out, so watch for that.
Using Scancode Map #
You can download Scancode Map from the GitHub releases page.
Steps:
- Back up your registry (important!) by opening the Registry Editor and choosing File > Export and saving the resulting file
- Open Scancode Map
- Add your mapping by clicking the plus symbol in the toolbar
- Click Apply
- Reboot
It also comes with a helpful scancode viewer to help you figure out key maps:
Using Microsoft PowerToys Keyboard Manager #
PowerToys can’t remap all keys, and some Windows key combinations won’t be remapped. Also, some games and applications may not recognize the PowerToys remapping.
Key advantages (pardon the pun) over the registry method:
- Change key maps without rebooting
- Map keys to key combinations
- Remap shortcuts
- Including app-specific shortcuts
Steps:
- Open PowerToys
- Right-click on the taskbar tray icon and click Settings
- Go to Keyboard Manager
- Enable Keyboard Manager
- Click Remap a key
- Click the plus sign
- Add your mapping
- Click OK at the top of the window to save the mapping
- On the warning dialog “The following keys have been reassigned…” click Continue Anyway
Docs for Keyboard Manager can be found here.
Conclusion #
Remapping those keys has made my Windows experience easier. I’m going to remap the Caps Lock key to Right Arrow, to make it more convenient to exit keys and brackets when I’m coding.
If you disabled the Windows key and used to use the Search/Run box in the Start Menu to open things, I suggest installing Microsoft PowerToys and using its PowerToys Run utility. It’s mapped to Alt + Space
by default and is similar to macOS’s Spotlight utility.
I like PowerToys Run more than the default Start Menu search, it’s faster and more accurate.
Reference #
- https://superuser.com/questions/1264164/how-to-map-windows-key-to-ctrl-key-on-windows-10
- https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/keyboard-and-mouse-class-drivers#scan-code-mapper-for-keyboards
- https://docs.microsoft.com/en-us/windows/powertoys/keyboard-manager