Map Caps Lock to Escape or any key to any key
Map Caps Lock key to Escape key, or any to any key, on Windows systems.
Apart from documenting how Uncap works on Windows, this README contains detailed documentation about how to remap keys on Linux and Mac as well.
The following list briefly describes some of the features of Uncap.
There are several other methods and tools available on Windows to map one key to another. But none of them seem to have all five features enumerated above. For example, editing Scancode Map registry value requires the Windows system to be rebooted after every change. On the other hand AutoHotkey requires an additional script file to be written. Therefore, Uncap was written to support all five features described above.
Uncap is a single-file executable: uncap.exe.
The simplest way to run it is to download it and double-click it. No output window is displayed. It runs in background. Once it is running, whenever Caps Lock key is pressed, it is translated to the Escape key by Uncap.
It is possible to override the default mapping of Caps Lock key to Escape key by specifying a custom mapping, however to do so, Uncap must be run with arguments either from Command Prompt or from Windows Run dialog box. The following steps show how uncap.exe may be used to map Caps Lock key to Left Control key.
Copy uncap.exe to a directory specified in the Windows PATH
variable. C:\Windows is a very convenient location to copy this
file to.
Launch Windows Run dialog box by pressing Windows Logo Key + R.
Enter the following command.
uncap 0x14:0xa2
Press OK button. This would launch Uncap. No output window would be displayed. Uncap would run in background. Whenever Caps Lock key is pressed now, Uncap would translate it to Left Control key.
To terminate Uncap, run the following command.
uncap -k
In the above steps, Caps Lock key is mapped to Left Control key by
specifying 0x14:0xa2 as an argument to Uncap. The virtual-key code of
Caps Lock is 0x14 and the virtual-key code of Control key is 0xa2.
Therefore, the argument 0x14:0xa2 maps Caps Lock key to Control key.
The list of virtual-key codes for every key can be found at .
When Uncap is run without any arguments, it maps Caps Lock key to Escape key. It may be run with arguments to map Caps Lock key to any key, any key to any key, or disable any key.
Each argument is a colon separated pair of virtual-key codes from .
The virtual-key code may be specified either as hexadecimal integer as mentioned in the above URL or its equivalent decimal notation. These details are illustrated in the list of examples below.
Map Caps Lock key to Escape key.
uncap
Swap Caps Lock key with Escape key.
uncap 0x1b:0x14
Caps Lock key is already mapped to Escape key by default. The above command maps Escape key to Caps Lock key, thus effectively swapping both keys.
The hexadecimal integer is case-insensitive, so the following command is equivalent to the previous command.
uncap 0x1B:0x14
The virtual-key codes may be specified in decimal notation, so the following command is equivalent to the previous command.
uncap 27:20
Map Caps Lock key to Left Control key.
uncap 0x14:0xa2
Swap Caps Lock key and Left Control key.
uncap 0x14:0xa2 0xa2:0x14
This example shows that it is possible to specify more than one argument to map multiple keys to other keys.
Here is another example that maps multiple keys to other keys. The following command maps Caps Lock key to Left Control key, Left Control key to Escape key and Escape key to Caps Lock key.
uncap 0x14:0xa2 0xa2:0x1b 0x1b:0x14
If a key is mapped to itself, then no mapping occurs for it. This may be used to override default behaviour of mapping Caps Lock key to Escape key and leave it unmapped while mapping another key to some key. Here is an example that unmaps Caps Lock key and maps F1 key to escape key.
uncap 0x14:0x14 0x70:0x1b
When a key is mapped to another key, and that key is pressed, Uncap translates it to the key it is mapped to by synthesizing a new keystroke and injecting it into the system. But when a key is mapped to itself, and that key is pressed, it is ignored, thus no translation or synthesis of a new keystroke occurs.
If a key is mapped to 0, then the key is disabled. Here is an example that disables Caps Lock key completely.
uncap 0x14:0
Uncap runs without displaying a console by default. To terminate
another instance of Uncap that may be running, use the -k or
--kill option.
uncap -k
The above command kills all other instances of Uncap that are running with or without a console.
To run Uncap with a console, use the -c or --console option.
uncap -c
When Uncap is running in a console like this, it may be terminated
by pressing Ctrl + C.
To run Uncap in debug mode, use the -d or --debug option.
uncap -d
The debug output contains one line of output with details about every press of a key or release of a key.
To log the keystroke details to a file, use the -f or --file
option.
uncap -f C:\keys.txt
With this option alone, Uncap runs in background and logs the
keystroke details to the specified file. This option may be
combined with -c or -d to run Uncap in a console or print
debug output on the console, respectively.
See the complete usage details along with options supported.
uncap -h
When Uncap is downloaded using the Microsoft Edge web browser on Windows 10, it sometimes fails to map keys.
The following measures have found to be unsuccessful in resolving the issue:
Right clicking uncap.exe, then selecting Properties, then
selecting Unblock, and then clicking OK does not resolve the
issue.
Right clicking uncap.exe, then selecting Properties, then going
to Security tab, then clicking Edit, and then removing the
following two accounts does not resolve the issue:
Unknown Account(S-1-15-2-3624051433-2125758914-1423191267-1740899205-1073925389-3782572162-737981194)
Unknown Account(S-1-15-3-3624051433-2125758914-1423191267-1740899205-1073925389-3782572162-737981194)
These accounts are added automatically to files downloaded with Microsoft Edge.
The following workarounds have been found to resolve the issue successfully:
Copy uncap.exe to a new file in the same directory. The new file
when run remaps keys successfully. Finally, delete the downloaded
uncap.exe, then rename the new file to uncap.exe, and use it
normally.
Copy uncap.exe to some other directory. The new copied file when
run remaps keys successfully.
This issue was observed with Microsoft Edge Microsoft Edge 44.17763.1.0 on Windows 10 Pro.
There are other tools and methods available to map one key to another on Windows, Linux and Mac. This section describes a few such tools and methods.
One way to map a key to another key in Windows without using any additional software is by editing the registry to add a value called "Scancode Map" in "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" registry key.
For example, to map Caps Lock key to Escape key, create a registration entries file, i.e. a file with reg as its extension, say uncap.reg, with the following content.
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
Then save the file. Then double-click this file to add it to Windows registry. Then reboot the Windows system. After rebooting, whenever Caps Lock key is pressed, it would function like Escape key.
The same registry value may be added by running the following command in Command Prompt.
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map" /t REG_BINARY /d 00000000000000000200000001003a0000000000
The hexadecimal code in the registry value is the scan code map. The format of the scan code map is described in detail at .
The following command may be used to view this registry value.
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map"
The following command may be used to remove this registry value.
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map"
While this method has an advantage that it requires no additional software, a disadvantage of this method is that it requires the system to be rebooted after every change in the registry.
There is a tool called SharpKeys that comes with graphical user interface to manage this registry value. However a reboot is still required after every change made with SharpKeys.
There is a fairly sophisticated scripting language for Windows called [AutoHotkey][] that can be used to map one key to another, among many other things.
It is quite simple to map one key to another using AutoHotkey. For example, after installing AutoHotkey, to map Caps Lock key to Escape key, create an AutoHotkey script, i.e. a file with ahk as its extension, say uncap.ahk, with the following content.
CapsLock::Esc
Then save the file. Then double-click this file to run AutoHotkey with this script. Once this is done, whenever Caps Lock key is pressed, it is translated to Escape key. An AutoHotkey icon appears in the notification area (system tray). To stop it, right click on the icon and select 'Exit'.
This
No open issues yet, or sync has not completed.