Can I switch the alt and ctrl keys on my keyboard? [duplicate]

I'm a long time Mac user, but I just built a PC. Not liking the ctrl and alt keys locations. I'm always expecting the ctrl key to be where the command key is on my Macbook. Can I moved swap these somehow? I'm running Windows 10, and I'm up to date.


For remapping any physical key on the keyboard is a registry entry.

It's in [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
You create a key with the name Scancode Map. It can redirect any key to another key or disable it.

That key is a hex-value with the following meaning:

00,00,00,00 Header: Version. Set to all zeroes.
00,00,00,00 Header: Flags. Set to all zeroes.
05,00,00,00 5 entries in the map (including null entry).
38,00,1d,00 Left CTRL -> Left ALT (can also be another key).
1d,00,38,00 Left ALT -> Left CTRL.
38,e0,1d,e0 Right CTRL -> Right ALT.
1d,e0,38,e0 Right ALT -> Right CTRL.
00,00,00,00 Null entry.

To swap the CTRL and ALT keys you need four entries (plus null).
The Left Left-CTRL (1d 00), the Left Left-ALT (38 00), the Right-CTRL (1d e0), and the Right-ALT (38 e0).

So you can create a .reg file like this: Disable_CTRL-key.reg

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,38,00,1d,00,1d,00,38,00,38,e0,1d,e0,1d,e0,38,e0,00,00,00,00

Execute (double click) the .reg file and log out and back in (or restart your computer). Now your CTRL and ALT keys should have been swapped.

Other useful keys to know:

1d 00    Left Ctrl
1d e0    Right Ctrl
38 00    Left Alt
38 e0    Right Alt
5b e0    Left Windows Key
5c e0    Right Windows Key
5d e0    Windows Menu Key

(Based on this answer by Rik)

If you are not comfortable with changing the registry or you want other keys too you can use the program SharpKeys to edit them more easily. It also has a convenient list of all keys so you can just add them in a window.

While SharpKeys (perhaps - I cannot actually verify that it did work) used to be an alternative option, SharpKeys' current Readme states that SharpKeys cannot be used for this purpose, although it can be used for other key remappings. (h/t gabe)


Alternatively, I found the Windows Server 2003 Resource Kit Tools (archived download) which contains a small executable called remapkey.exe, only 340KB in size. It is a graphical program which allows you to remap the keys of your keyboard. A reboot is required, as with any manual change. In Windows Vista+ it will require Admin privileges.

While looking for some screenshots, I came across another answer on this site which recommends it:

The best tool for the job is Microsoft's own remapkey, available as part of the Windows Resource Kit. (That link is for Windows 2003; I've used it successfully over the years on many versions of Windows, including Windows 7; have not tested Windows 8).

remapkey will write the mapping directly into the registry, I believe, and does not require a running process. You simply drag from actual key to desired key, and save.

remapkey screenshot


Further Reading:

  • https://www.experts-exchange.com/articles/2155/Keyboard-Remapping-CAPSLOCK-to-Ctrl-and-Beyond.html

The key remapping utility Sharpkeys (Download) should let you rebind your keys however you'd like. (Source)

Steps:

  1. Open Sharpkeys and click Add
  2. Add the following two entries as key mappings

    From:                           To:
    Special: Left Alt (00_38)       Special: Left Ctrl (00_1D)
    Special: Left Ctrl (00_1D)      Special: Left Alt (00_38)
    
  3. Confirm your remappings, then click Write to Registry