How to change ctrl key to AltGR key by editing registry?

3

2

I'm changing the Caps key to Ctrl by using this registry key:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]             
"ScancodeMap"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

And I want to use the original Ctrl key as another modifier for AutoHotkey. So I thought Alt GR is a good choice to use as a modifier.

But I couldn't figure out how to remap the original Ctrl key to Alt GR. Does anyone know how to change it via registry?

If there is better solution, I will go for it.

I'm using windows 10.

ironsand

Posted 2016-05-31T22:13:01.297

Reputation: 1 757

::Ctrl; Send {alt}{GR}; Is that the result you're looking for? – ejbytes – 2016-06-03T23:16:46.967

@ejbytes The way I read it, he is looking to change his Ctrl key to an AltGr key in way that AHK doesn't recognize his Caps Lock key as a Ctrl key, because he edited the registry to rebind it that way. – TheKB – 2016-06-04T09:01:06.760

@ejbytes Sorry, I couldn't figure out how the code works. – ironsand – 2016-06-04T21:06:22.563

@TheKB I want let AHK recognize Caps Lock as a Ctrl and original Ctrl as a AltGr. I'm not sure I'm understanding correctly what you wrote. – ironsand – 2016-06-04T21:08:13.300

@ironsand Yes, that's what I wrote. – TheKB – 2016-06-05T08:36:41.970

@ironsand Has my method worked? – TheKB – 2016-06-08T16:17:33.163

Answers

2

Method 1: Use SharpKeys


You could use SharpKeys to remap your keys. This changes the registry for you and allows you to easily manage key mappings.

  1. Click Add on the main screen
  2. Under Map this key click Type Key and press Ctrl
  3. Under To this key find and click AltGr
  4. Click Ok
  5. Click Write to Registry and then logout

Note: You may have to do steps 1-4 again for Caps to Ctrl
Edit: It appears that the key AltGr is not supported by SharpKeys. However, this answer is still valid for other keys so I will leave it for informational purposes. The registry method of rebinding, outlined below, works for this key remap.
Source

Method 2: Use the Registry


If you want to do it via the registry you can do:

00 00 00 00 00 00 00 00 03 00 00 00 aa aa bb bb aa aa bb bb 00 00 00 00

It's a bit complicated but I will try to explain. For remap 1, aaaa is the scancode of the key you want to map to. bbbb is the scancode of the key you want to map from. Same thing for remap 2. This is what you would put into the registry key ScancodeMap and what SharpKeys does for you.

A table showing the values and meaning of the DWORDS:

        Value:     Interpretation:                                          Entered as: 
DWORD 1 0x00000000 Header: Version. Set all to zeroes                       00 00 00 00 
DWORD 2 0x00000000 Header: Flags. Set all to zeroes                         00 00 00 00 
DWORD 3 0x00000002 Number of entries in the map, including null terminator  02 00 00 00 
DWORD 4 0x003A0000 Remove CAPS LOCK (0x3A --> 0x00)                         00 00 3A 00 
DWORD 5 0x00000000 Null Terminator                                          00 00 00 00 

In the above table, the mapping of Caps Lock is an example. Also, thanks to @Guitar Shoe Dave for the suggestion.
Source


In your case the value would be:

00 00 00 00 00 00 00 00 03 00 00 00 1d 00 3a 00 1d 02 1d 00 00 00 00 00

Note: You'll have to logoff and back in again to see the resulting changes.

TheKB

Posted 2016-05-31T22:13:01.297

Reputation: 813

I installed SharpKeys, but I couldn't find AltGr key in to this key list. What is the exact name of the key? – ironsand – 2016-06-04T21:19:44.450

@ironsand It appears that it is not there. But I believe 1d02 is the scancode for AltGr (I used the on-screen keyboard to test this) So the registry entry would be 00 00 00 00 00 00 00 00 03 00 00 00 1d 00 3a 00 1d 02 1d 00 00 00 00 00. Could you try this and see if you get the correct results? – TheKB – 2016-06-05T11:59:36.073

Please consider adding protocol documentation related to scancodes. Here's one which breaks it down a bit.

http://www.mech.utah.edu/~bamberg/resources/CapsLock/CapsLock.html
Also, here's a good reference of scancodes to include the long lived power management buttons (these ones are fun to play with) https://www.win.tue.nl/~aeb/linux/kbd/scancodes.html . I love your reply.

– NotAdmin Dave – 2016-06-09T20:47:36.430