45

Many applications like Google Docs use Ctrl+Alt shortcuts like Ctrl+Alt+2 for heading 2, Ctrl+Alt+m for comments etc. However, in case of international keyboards' layouts, Ctrl+Alt is mapped to AltGr, so many of these shortcuts produce special characters instead, e.g. Ctrl+Alt+2 = @. Therefore these shortcuts can not be used.

Is there a way to disable this Ctrl+Alt = AltGr, such that AltGr+2 = @ but Ctrl+Alt+2 can be used as a shortcut?


There has been some earlier post with answers related to this problem:

Both solutions are however related to unassign the special character completely. These solutions do not disable the Ctrl+Alt = AltGr binding. This means, that in order to use Ctrl+Alt+2 as a shortcut, I am not able to write @ at all, which is naturally not an option.

2
  • 3
    Did you try AutoHotKey
    – Dave
    May 8, 2013 at 8:37
  • Did you ever make the script? If so, could you share it?
    – mancestr
    Dec 7, 2016 at 17:44

9 Answers 9

22
+50

I have researched further and looked at the other answers. It seems like the short answer is: No! Windows treats Ctrl+Alt and AltGr identically.

But there is a hack. Essentially we do not let Windows handle AltGr key bindings and instead use a third party tool that knows the difference. We do this manually for every singe key.

This hack does not work with "dead keys" such as ~ or ^.

.

Part 1: Let AutoHotKey convert AltGr+Some Key to symbols
AutoHotKey can distinguish between AltGr and Ctrl+Alt. It can also transform keystrokes like AltGr+2 to a single symbol @, before Windows applies its keyboard layout.

  1. Download and install AutoHotKey
  2. Create a new script, i.e., a plain text file with the extension .ahk
  3. For each character you want to write with AltGr+BUTTON=CHAR, create a line like this:
    <^>!BUTTON::SendInput {raw}CHAR
    Example: AltGr+2=@ becomes <^>!2::SendInput {raw}@
  4. Save the script

If you want to test your script, you can create some arbitrary mapping like <^>!t::SendInput {raw}tttt. Double click the script to apply it and test if AltGr+t produces four t's when you type.

.

Part 2: Get windows out of the way:
We want to remove all assignments of AltGr+Any Key on they keyboard, so Windows never convert them into characters.

First we need to create a new keyboard layout.

  1. Download The Microsoft Keyboard Layout Creator. It is a simple tool that lets you modify your keyboard layout. (Download link)
  2. Open to tool and File -> Load Existing Keyboard and choose your keyboard layout.
  3. Select File -> Save source as and give it a new name.
  4. Tick the Alt+Ctrl (AltGr).
    You might want to select File -> Save as Image to make a note of the original assignments.
  5. Remove all assigned keys, by clicking them, deleting the symbol, and click OK
    Do not clear any dead keys! (The grey ones). Check for all modifiers i.e. AltGr, Ctrl, Alt, or none!
  6. Go to Projet -> Propertie and give it a decent name and description.
  7. Save it: File -> Save Source File so you can edit it later
  8. Export setup: Project -> Build DLL and Setup Package

Then we need to apply this new keyboard layout.

  1. Find the exported setup files in you Documents folder, and double click setup.exe. This will install your new keyboard layout.
  2. Open the input setting by going to Control Pannel -> Change keyboards and other input methods -> Change keybords
  3. Click Add select you own keyboard and make it default.
    Come back here and remove the standard keyboard, once your confident everything works well.

.

Part 3: Let AutoHotKey take over:
Now lets put everything into action:

  1. Make sure your new keyboard is selected in the language task bar, and AutoHotKey is not running minimized in the notification tray.
  2. Try to type your special characters. This should not work.
  3. Double click on you AutoHotKey script. So it launches
  4. Try to type special characters again. This should now work with AltGr only.
  5. To make sure the script is loaded when Windows starts, create a short-cut to it in the Start Menu\Programs\Startup folder

That's it! (ツ) You can share the keyboard layout setup files and the .ahk script, with other computers to skip most of the steps.


Other resources:
http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/replace-default-windows-keyboard-shortcut-behavior/0c5ff2a4-6bea-49a9-88bc-669049a1e107
http://office.microsoft.com/en-us/word-help/alt-gr-keys-HP005259063.aspx
https://devblogs.microsoft.com/oldnewthing/20040329-00/?p=40003
http://www.autohotkey.com/board/topic/61625-how-to-avoid-that-ctrl-alt-altgr/

7
  • Another valuable resource is Michael Kaplan's blog. Sep 28, 2013 at 19:58
  • 2
    removing AltGr+Key assignments will only work if your language doesn't require the use of AltGr
    – phuclv
    Jul 19, 2018 at 17:18
  • I got this to kind of work. Problem is the Keyboard Layout Creator is buggy. Be prepared to install and uninstall layouts multiple times. Sometimes uninstalls don't work the first time. The description doesn't update properly, which you can fix in the registry Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts`, the DLLs can be found in System32`. I give up at making this work 100% at this point
    – CervEd
    Dec 2, 2019 at 11:08
  • Seems like Windows needs to reboot to do some keyboard related things, like reflect updated descriptions and removing deleted keyboards from the control panel. This was way more of a pain in the ass then I had hoped. Seems to work okay now though. Had to create explicit capitalization commands in AutoHotKey, ie both <^>!q::SendInput {raw}ä and <+<^>!q::SendInput {raw}Ä
    – CervEd
    Dec 2, 2019 at 11:23
  • What if I want the opposite? I want AltGr characters to work normally, but I don't want the shortcuts bound to Alt+Ctrl to steal and disable my special characters available with AltGr. In Polish keyboard, AltGr+s gives "ś" but if a programs maps Ctrl+Alt+s, then I can no longer type "ś". Is it fixable? I mean to Ctrl+Alt+s to activate a shortcut, but AlgGr+s type "ś"?
    – Harry
    Feb 1, 2022 at 14:10
1

I would recommend you to have a look at AutoHotKey. Its a free Tool and you can also change shortcut-effects very easy. Have a look at the Hotkey-Documentation at their website. It is really easy to understand and really easy to use. You can remap every key/shortcut.

1

I found out that the numeric keyboard can be used instead of regular number keys to activate Google Docs shortcuts. Using AHK this works also on laptops without numeric keys. For example,

<^<!2::SendInput ^!{Numpad2}

will activate header 2 without printing @. No need to use MSKLC.

1

Depending on your current Windows keyboard layout your AltGr key will translate either to Right Alt + Left Control (e.g. on International US, Russian or Polish Pro layouts), or just to Right Alt (e.g. on English US layout). And as far as I know there is no way on Windows to have AltGr on the international layouts to be distinguished from Right Alt + Left Control simultaneous combination.

But, depending on your needs, you can workaround this with the help of AutoHotKey.

If you use the international layout just to be able to enter a couple of characters like diacritics, then you can switch to the corresponding non-international layout, which does not treat AltGr as Right Alt + Left Control, like English US layout, and just add the AutoHotKey script for the special characters you need. E.g.

>!2::SendInput "{Text}²"

will enter ² when you press Right Alt + 2 on English US layout. The Ctrl+Alt+2 combination will not be affected and will be free for other usage.

If you still need to use your international layout, then you'll need to change the AutoHotKey script above to

<^>!2::SendInput "{Text}²"
^!2::SendInput "^!2"

which will enter ² when you press AltGr + 2 or Left Control + Right Alt + 2, and leave all other Alt + Ctrl + 2 combinations free for use.

Depending on the application, the script above may not work though. E.g., on Google Docs under Chrome, it will always enter ² for any combinations of Alt + Ctrl + 2.

To workaround this, we may use the fact, that AltGr maps to Left Ctrl + Right Alt pressed simultaneously. E.g., even w/o AutoHotKey we can enter comment mode on Google Docs with International US keyboard, if we press down Ctrl then press down M then press down Left Alt and then release the keys. But it's not practical to think in what order to press and release the keys. Instead, we may use AutoHotKey for that and change the second line of the script above:

<^>!2::SendInput "{Text}²"
^!2::SendInput "{RCtrl down}{2 down}{LAlt down}{2 up}{LAlt up}{RCtrl up}"

Sometimes, the problem is the opposite: you want to enter some diacritic with AltGr+XXX combination, but that triggers some action bound to Alt+Ctrl+XXX combination. E.g., on Polish Programmers layout, if you press AltGr+S to enter Ś diacritic, the Windows Snipping Tool pops up instead on Windows 11. And of you have Evernote installed, then pressing AltGr+N to enter Ń diacritic opens Evernote window to create a new note. This is easily fixable with AutoHotKey. E.g., the problems above need only two corresponding lines:

<^>!N::SendInput "{Text}ń"
<^>!S::SendInput "{Text}ś"

After that AltGr+N and AltGr+S will correctly enter the corresponding diacritics, while other Ctrl+Alt+N or Ctrl+Alt+S combinations will trigger the appropriate action, like opening the Snipping Tool or New Note window.

Note, that you need to add only those problematic combinations, no need to enter all the existing diacritics.

As a bonus, here is an interesting history behind the Poland Programmers layout.

0

I would recommend SharpKeys:

SharpKeys is a Registry hack that is used to make certain keys on a keyboard act like other keys. For example, if you accidentally hit Caps Lock often, you could use this utility to map Caps Lock to a Shift key or even turn it off completely. This official release includes support for up to 104 mappings, an extensive list of available keys, and a "Type Key" option to help when managing mappings.

I have not used it personally, but know someone who has used it in the past and is quite happy with it.

I am not sure, But maybe switching your keyboard layout to (English UK) might help. Here is a link on how.

1
  • Took a look at SharpKeys, but it only seems to map one key stroke to another and doesn't do combinations, so it is not helping :( Switching keyboard layout is not an option, since most symbols are in other locations - even the number of keys are different. But thanks for suggestions.
    – Bittenus
    Sep 26, 2013 at 8:47
0

I found a way around this in Windows 10 Settings > Typing > Advanced Keyboard Settings > Override for Default Input Method Change to a non-international Keyboard (as per your Advanced Keyboard Settings) Hope that works for others

0

If you don't need any or only a few of the Alt+Gr keyboard combinations, you can create a custom keyboard layout that removes all the unneeded ones.

For example, these are the only one that I kept in my custom layout:

custom keyboard layout

I created a repository for myself, but it might be interesting for others as well: https://github.com/fvclaus/windows-us-custom-keyboard-layout

-1

One good developer BladeMight offered his own workaround for international layouts (the best and trouble-free in my opinion) with Mahou app: at the time of typing Ctrl+Alt+ combinations, the keyboard layout will temporarily change to special one where the symbol mode doesn't involve duplicating AltGr to Ctrl+Alt.

Just open Mahou "Layouts" tab and enter in "Temporary change layout on LCtrl+LAlt combination" field: 67699721 (English US code), then click on "Apply" button.

You can freely specify any other (desired) keyboard layout (without AltGr) code for a temporary change (but it makes no difference).

Download (x64): Direct link

Other builds

Here are my settings: https://i.imgur.com/Auh6xHu.png

-3

press and hold the NumLock key for 5 seconds.

This worked for me.

I found the answer on the computer here: "Control Panel\All Control Panel Items\Ease of Access Center\Make the keyboard easier to use" ... Mine has a tick next to 'turn on toggle keys by pressing and holding NUMLock for 5 seconds'....

1
  • Please clarify and add a little more context to this answer to convey what you are suggesting exactly. You know, consider adding some reference to this answer supporting what you state. Otherwise, read over "Why do I need 50 reputation to comment" to ensure you understand how you can start commenting. Aug 18, 2017 at 14:26

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.