Tomas Sedovic
Tomas Sedovic

Reputation: 44393

How to globally map AltGr key to Alt key?

I want my AltGr key to behave exactly like left Alt.
Usually, I do this kind of stuff with Autohotkey, but I'm open to different solutions.

I tried this:

LControl & RAlt::Alt

And Autohotkey displayed error about Alt not being recognized action.
Then I tried the following code:

LControl & RAlt::
  Send {Alt down}
  KeyWait LCtrl
  KeyWait Ralt
  Send {Alt up}
return

which sort of works - I'm able to use the AltGr key for accessing hotkeys, but it still behaves differently:
When I press and release the left Alt, the first menu item in the current program receives focus.
Pressing and releasing AltGr with this script does nothing.

Any ideas? Is this even possible with Autohotkey? (remapping right Ctrl and Shift to their left siblings was piece of cake)


Note: I tried switching Alt to LAlt in the code and it made no difference.

Upvotes: 50

Views: 55661

Answers (8)

AdsTable
AdsTable

Reputation: 1

KeyTweak - only this worked for me.

Upvotes: -1

Ashish Porwal
Ashish Porwal

Reputation: 21

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,38,00,38,e0,00,00,00,00
  1. Save the above code in reg file.
  2. Merge it in registry.
  3. Restart your PC.
  4. Now check.

Upvotes: 1

Tomas Sedovic
Tomas Sedovic

Reputation: 44393

Thank you all for answers. I was unable to solve this using AutoHotkey -- PhilLho's answer was close, but I really needed exatly the same behaviour as with left Alt key.

However, the registry thing actually worked as I needed.

Save this as AltGR_to_LeftAlt.reg file and run it:

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

Or, there is a GUI tool that does this for you -- it's called SharpKeys and works peachy:
SharpKeys in action

Oh, and don't forget to reboot or log off -- it won't work until then!

Upvotes: 59

PhiLho
PhiLho

Reputation: 41162

I got a decent behavior by combining two hotkeys:

LControl & RAlt::Send {Alt}
RAlt::Alt

The first one is for the standalone keypress (avoid to hold it down...), the second one to be used as combination (Alt+F, etc.).
It isn't perfect, you can't do a combination like Ctrl+Alt+T, but perhaps it is enough for your needs.

Note that you can do a permanent remapping using the registry. See this forum post for an example. Not sure that it applies to compound keys like this one, but I thought I should mention it...

Upvotes: 4

Ronald Blaschke
Ronald Blaschke

Reputation: 4184

As pointed out by PhiLho, Windows provides a way to remap any key, through the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout. A basic overview can be found at Scan Code Mapper for Windows. A better description is probably Answers to Scancode Mapping or Changing Key Values.

I'm using this approach to put the Windows Key on the Caps Lock, because my keyboard doesn't have a Windows Key and I don't need the Caps Lock.

Upvotes: 9

pbies
pbies

Reputation: 742

If you want to map this key globally and with no need to restart system for every change (but once), you may need to write a keyboard filter driver for this purpose. Look here.

Upvotes: 0

Dave James Miller
Dave James Miller

Reputation: 5308

This worked for me:

LControl & *RAlt::Send {LAlt Down}
LControl & *RAlt Up::Send {LAlt Up}

And this for mapping it to the Windows key:

LControl & *RAlt::Send {LWin Down}
LControl & *RAlt Up::Send {LWin Up}

Registry modification using SharpKeys (see above) is more reliable though (if you have administrator access).

Upvotes: 3

Brian Schmitt
Brian Schmitt

Reputation: 6068

In AHK, Can you do:

LControl & RAlt::!

Or

<^>!::!

Upvotes: 0

Related Questions