71

In windows 8 I used to remap my capslock key to control using the registry script

REGEDIT4

[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

After having upgraded to window 10, this does not work anymore. How can it be done?

  • Note this only remaps Caps Lock to another Ctrl key. I want them swapped, so I used the instructions here to tweak the script above: superuser.com/a/1202601/315584 – jia103 Sep 20 '17 at 15:00
73

Did you remember to re-boot? Seems to work fine for me, just like in 7 and 8.

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
  • 8
    The issue for me was that the Windows 10 upgrade reset my caps lock mapping. But doing it again the same way worked after another restart. – Jack O'Connor Dec 1 '15 at 2:48
  • 31
    If anyone else like me needs the final piece of the puzzle: paste the above into a new text file, save it with the .reg extension, double click the file to apply the changes to the registry, then reboot. – Mike Niebling Sep 6 '16 at 0:00
  • 3
    How do you map it back to Caps Lock afterwards? – Ehtesh Choudhury Dec 1 '16 at 1:36
  • 2
    @EhteshChoudhury you can delete the "Scancode Map" entry under the registry key, reboot, and default behavior will be restored. – bojolais Apr 11 '17 at 19:16
70

In case anyone needed this done via PowerShell:

$hexified = "00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00".Split(',') | % { "0x$_"};

$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';

New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified);

Run it as Administrator and reboot.

  • 11
    Have an upvote for giving a Linux-like "copy&paste into shell" answer! – mikezter Sep 8 '17 at 8:44
  • 2
    Seriously. I miss having *initrc scripts. Thanks. – stewSquared Apr 24 '18 at 20:18
  • 3
    You sir, have made using Windows today a slightly less miserable experience. For that, I thank you. – binarymason Jan 23 at 19:25
18

You can use SharpKeys to map any key to any other key in Windows 7, 8, or 10. It's much easier and cleaner to do than to modify the registry yourself.

Hope this helps.

  • Can I use this to switch languages by pressing caps lock ? – thanos.a Jan 5 at 17:34
6

I use the following to send CTRL for the CAPS LOCK key, send ALT for the CTRL key, and send CAPS LOCK for the ALT key. CTRL is to the left of "A" where God intended it, ALT is below SHIFT, and the utterly useless CAPS LOCK key is safely tucked away where I have to break my wrist to hit it.

Windows Registry Editor Version 5.00

; The hex data is in five groups of four bytes:
;   00,00,00,00,\    header version (always 00000000)
;   00,00,00,00,\    header flags (always 00000000)
;   04,00,00,00,\    # of entries (3 in this case) plus a NULL terminator line.
;                    Entries are in 2-byte pairs: Key code to send & keyboard key to send it.
;                    Each entry is in LSB, MSB order.
;   1d,00,3a,00,\    Send LEFT CTRL (0x001d) code when user presses the CAPS LOCK key (0x003a) 
;   38,00,1d,00,\    Send LEFT ALT (0x0038) code when user presses the LEFT CTRL key (0x001d) 
;   3a,00,38,00,\    Send CAPS LOCK (0x3A) code when user presses the LEFT ALT key (0x0038) 
;   00,00,00,00      NULL terminator

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,\
                   00,00,00,00,\
                   04,00,00,00,\
                   1d,00,3a,00,\
                   38,00,1d,00,\
                   3a,00,38,00,\
                   00,00,00,00
  • 2
    I really appreciate the comments. I always wondered what the codes meant. Very helpful. – zaphodtx Aug 8 '18 at 22:01
2

You can use lswitch to remap language input to CapsLock.

Use any key to switch input languages, usage: lswitch [keycode]. Keycode is optional and defaults to context menu key. Another good candidate is a CapsLock key with a keycode of 20.

lswitch 20

Add it to autoload.

  • this works, however the caps lock functionality is lost. any idea on how to define the caps lock functionality to shift+caps lock combination? – thanos.a Jan 5 at 17:51
1

This is the script to swap CTRL and CAPS LOCK keys:

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,3a,00,3a,00,1d,00,00,00,00,00
1

The inexhaustible sysinternals toolbox also provides a little program just for switching capslock with control -- ctrl2cap.exe.

  • Welcome to Super User. Please read How to Recommend Software then edit your answer to include at least the minimum required information (the items in bold). Posts without this information may be subject to deletion. Thanks for contributing. – Twisty Impersonator Dec 31 '18 at 18:06
0

I used to use AutoHotKey to do this.

I'd have a link in the startup directory to run a very basic ahk script:

Capslock::Ctrl

The thing is, Autohotkey isn't run as Administrator so it won't affect privileged windows, unless you use the task scheduler instead of the startup directory to run the script at login with higher privileges. The second problem is that sometimes, the script hangs when resuming sleep, so you may need to reload it, which is annoying.

AutoHotKey is better suited for more complex tasks, like writing macros.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.