50

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.
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
Tomas Sedovic
  • 42,675
  • 9
  • 40
  • 30

7 Answers7

57

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!

it3xl
  • 2,372
  • 27
  • 37
Tomas Sedovic
  • 42,675
  • 9
  • 40
  • 30
  • 4
    This answer is wrong: SharpKeys does not support Alt Gr. (https://sharpkeys.codeplex.com/workitem/10375) – Nye Jan 03 '15 at 20:16
  • 3
    `Right Alt` worked as a substitute for `AltGr` for my purposes (remapping bootcamp `Cmd` to `AltGr`), with the one difference that I had to select it manually from the list. "The right Alt key is usually an equivalent of the AltGr key" - http://en.wikipedia.org/wiki/AltGr_key – Andreas Mar 03 '15 at 23:02
  • 5
    This answer is correct. I have successfully remapped my left and right ALT keys on my mac keyboard with SharpKeys. You need two mappings, one for `left<=>right` and `right<=>left` swapping of ALT keys. – nover Sep 02 '15 at 06:47
  • How do you undo this please? – Richard Jul 02 '22 at 12:23
8

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.

robert
  • 4,612
  • 2
  • 29
  • 39
Ronald Blaschke
  • 4,036
  • 2
  • 22
  • 16
  • 1
    Since I'm not supposed to add software to my work machine, this is really useful. I used the Scan Code Mapper for Windows link to map Caps to Ctrl before stumbling across the ready-made reg file at ["Is it worth swapping Ctrl and Caps..."](http://stackoverflow.com/questions/127973/is-it-worth-swapping-ctrl-and-caps-lock-for-windows-users-that-dont-use-emacs). – sage Jan 03 '11 at 22:10
3

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...

Syscall
  • 19,327
  • 10
  • 37
  • 52
PhiLho
  • 40,535
  • 6
  • 96
  • 134
3

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).

Dave James Miller
  • 4,928
  • 3
  • 20
  • 18
1

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.
user4157124
  • 2,809
  • 13
  • 27
  • 42
0

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.

Community
  • 1
  • 1
pbies
  • 666
  • 11
  • 28
0

In AHK, Can you do:

LControl & RAlt::!

Or

<^>!::!
Brian Schmitt
  • 6,008
  • 1
  • 24
  • 36
  • Sorry, but it does not work for me. The first examples returns the "not recognized action" error and the second one does nothing at all. Of course, it is possible that something is wrong with my setup. Did it work on your side? – Tomas Sedovic Oct 23 '08 at 14:36
  • I don't have the key, but looking in the AHK documentation showed this that the <^>! is the symbol for AltGr. Right Click TrayIcon-->Help-->Hotkeys – Brian Schmitt Oct 24 '08 at 15:07