Why are programs allowed to use normal characters as hotkeys?

alv wonders why programs are allowed to create hotkeys for normal characters. The example given is the famous AltGr modifier, equivalent to Ctrl+Alt. Programs which ignore the guidance and use Ctrl+Alt as a shortcut modifier end up stealing keys from many non-English keyboard layouts, thereby preventing users from typing things like the Euro sign € (which is an AltGr combination on most keyboards that support it), or even worse, preventing Polish users with the Polish programmer keyboard layout from typing the letter Ż.

Given that using Ctrl+Alt as a keyboard shortcut modifier can prevent people from typing perfectly legitimate letters, why does Windows allow it in the first place?

Because there are many cases where it is acceptable to commandeer keyboard sequences that would otherwise result in normal typing. You do it all the time and probably don't realize it.

For example, in an edit control, the Ctrl+A shortcut is frequently overridden to mean select all instead of entering a literal U+0001 into the edit control text. You probably would go crazy if you lost the Ctrl+C, Ctrl+X and Ctrl+V hotkeys. Ctrl+Z for undo is also pretty popular. And who can forget TAB for dialog box navigation. And imagine the riots if ESC couldn't be used as a hotkey any more.

There are some programs which go so far as to use normal typing characters as hotkeys. For example, an email program might let you compose a new message by simply pressing N. That's just the letter N, unshifted, unmodified.

Given that there are legitimate reasons for allowing normal typing to be treated as a hotkey, implementing a global ban on that behavior would break a lot of scenarios that you personally would almost certainly want to keep working. Of course, it also means that it's the programmer's responsibility to think twice before stealing a keyboard sequence that can be used for normal typing. If the user is actually typing, you may have stolen something you should have left alone.

You can't even have the rule "all shortcut keys which correspond to normal typing are automatically disabled when focus is on an edit control" because you would lose hotkeys like Ctrl+C and TAB, as noted above, as well as scenario-specific hotkeys such as having the IPv4 control automatically jump to the next octet when you press ..

Comments (36)
  1. Adam Rosenfield says:

    I think that Ctrl+Alt is a different beast altogether — that shortcut is all modifier keys without any terminal non-modifier key.  With the exception of games (which typically let you bind functions to most keys), I usually find it surprising when a program takes action on bare modifier keys.

  2. Mike Caron says:

    @Adam: Try pressing Alt by itself.


    There are some programs which go so far as to use normal typing characters as hotkeys

    Imagine the chaos that would break out if vim were to stop working :)

  3. CAD says:

    > With the exception of games (which typically let you bind functions to most keys), I usually find it surprising when a program takes action on bare modifier keys.

    You would be surprised by most CAD application, then, image viewers, image editors and many others. Having modifiers in those apps would seriously slow down work for no gain at all.

  4. Sean says:

    I use a multitrack audio workstation application, which can assign various shortcuts and macros to any key on the keyboard, with or without modifiers.

    However, it does nto cause any issues, since there is very little actual typing possible in the application, and when there is a text-entry field, it bypasses the assigned shortcuts whilst the text field is active.

  5. Joshua says:

    Besides, somebody doing while(GetMessage(…)) { if (condition on message) { do something } else { TranslateMessage(); DispatchMessage(); }} defeats almost any block.

  6. Yuri Khan says:

    I have always thought the only place where an IPv4 address control can be legitimately used is the system dialog for manually entering the DNS server addresses. In all other places where an IP address is expected, the user should be able to type a DNS name and have it looked up automatically and transparently.

  7. Kevin says:

    @Yuri: Not all servers have domain names, though it's sketchy to not have one.

  8. alv says:

    In fact, my original question was specific to AltGr – since it came late to the show, lots of programs fail to handle it correctly, unlike the examples in the explanation above. What I've never really understood is why wasn't the AltGr key introduced as a completely new key (like the Windows key), keepint Ctrl+Alt as a compatibility shortcut.

    [Isn't that the current situation? AltGr is a completely new key, and Ctrl+Alt is a compatibility shortcut for keyboards that don't have that new key (or if you just like typing it the slow way). -Raymond]
  9. Adam Rosenfield says:

    @Mike: Holding Alt to show keyboard shortcuts and releasing it to access the menu bar is an established convention; it's not surprising, as long as applications don't deviate from the usual behavior.

    @CAD: I'm not sure what you're getting at there.  I was talking about using a bare modifier key like Ctrl to invoke some action, but it sounds like you're referring to using a bare non-modifier such as W for a hot key.  Sure, that's not as common as hot keys with modifiers, but it's not highly unusual.

  10. Dave says:

    @alv: Hardly late to the show as IBM introduced the "enhanced" keyboard with the two Alt keys in 1986, with non-US keyboards having the right one replaced with Alt Gr.

  11. alv says:

    @Dave: Yes, 1986 was late to the show, as programs already used Ctrl+Alt+[X] shortcuts that time.

  12. kinokijuf says:

    Thanks for the mention of Polish users. I am from Poland and agree that it’s a total PITA.

  13. It is quite common to connect to your local router's web interface by IP rather than by domain name.

  14. Adam: "I was talking about using a bare modifier key like Ctrl to invoke some action"

    What's the default keystroke to release a captured cursor in VMWare?  Right-Ctrl?

  15. Joshua says:

    I think hacksoncode is talking about shortcuts placed in the start menu or on the desktop with a registered hotkey that is Ctrl+Alt.

    [Oh, you're talking about the hotkey control in the Shortcuts property page. Well, that also let you set up a global shortcut for Ctrl+C, which is probably equally unwise… -Raymond]
  16. alv says:

    @Raymond: no, it's not the same. I'd propose having a new key code for AltGr instead of being a shortcut for Ctrl+Alt, and having Ctrl+Alt as a shortcut for AltGr – today it's the other way round. Let me explain in details:

    – Currently, using the Hungarian layout where '@' is mapped to AltGr+V, when AltGr+V is pressed, the application receives a WM_KEYDOWN message with wParam='V', GetKeyState(VK_MENU)!=0 and GetKeyState(VK_CONTROL)!=0, followed by a WM_CHAR message with wParam='@' – exactly the same as when pressing Ctrl+Alt+V.

    – In my ideal world, when AltGr+V was pressed, the application would receive a WM_KEYDOWN message with wParam='V', GetKeyState(VK_MENU)==0 and GetKeyState(VK_CONTROL)==0 (and something like GetKeyState(VK_ALTGR_DONTUSETHISFORSHORTCUTSORELSE)!=0), followed by a WM_CHAR message with wParam='@' – but for compatibility with keyboards lacking the AltGr key, pressing Ctrl+Alt+V would have the same result as today.

    And i also think it wouldn't be too late to implement something like this in some future release (or if it's hardwired in the keyboard then convince the manufacturers to support it, just like the Windows keys). At least it would fix more problems than it would create :)

    [If somebody types Ctrl+Alt+V, should GetKeyState(VK_ALTGR_DONTUSETHISFORSHORTCUTSORSELF) return "yes" or "no"? I think I'm seeing where you're coming from — you want it to be like VK_APPS, where an app has to respond to both the new key and the fallback one (Shift+F10) if it wants to cover both invoke paths. Maybe for typing this wouldn't be such a bad idea. (For general hotkeys, it's more frustrating for the developer.) -Raymond]
  17. Adam Rosenfield says:

    @Timothy: I don't know, I don't use VMWare, but VirtualBox does use Right Ctrl for that by default.  Yes, I find that behavior a little surprising, but surprising does not mean wrong.  VMMs are complicated pieces of software.

  18. Joshua says:

    @Adam Rosenfield: The point is to capture a key so unlikely to be direct bound by any software inside it that you don't get serious usability collisions. It's not too hard to retrain your key habits to not use right control as a modifier key.

  19. Anonymous Coward says:

    Before I say anything else, let me first get this of my chest: if a program is obnoxiously annoying, then don't use it.

    Okay then, point by point:

    1) First and foremost: that was not what Alv asked. Maybe Raymond hoped we wouldn't click the link.

    2) Nitpick: all keyboards support €. It's the keyboard layouts that matter, which put it under AltGr+5, AltGr+4 or AltGr+E (and maybe others which I know nor care about). I assume Raymond knows this, but his readership might not.

    3) Adam Rosenfield, I think that discussion was mostly about software assigning e.g. zoom 500% to AltGr+5 while you need it to enter €.

    4) Saying ^A is a perfectly normal U+0001 is missing the point. No sensible person considers ^A to stand for a normal character. Which is probably why the edit control seems to ignore them all, even those it doesn't use as a hot-key.

    5) Joshua raises an important point. Even though it could make some sense to police the edit control, people can always get around any block and if you make it hard enough they'll just reimplement it. Some applications have done precisely that anyway for different reasons, like most web browsers and word processors.

    6) As an actual response to Alv, yes it's possible to prevent applications from interpreting AltGr+[X] as a hot-key. This is done by shimming the relevant message functions to change the key messages into bare character messages, similar to the messages an IME sends.

  20. Anonymous Coward says:

    Okay, I see Alv has replied in this thread; he hadn't yet when I posted. If you want Ctrl+Alt to behave differently from AlgGr, you could make your shim set a flag depending on the contents of WM_SYSKEYDOWN.

  21. alv says:


    For Ctrl+Alt+V, GetKeyState(VK_ALTGR_DONTUSETHISFORSHORTCUTSORSELF) should be definitely "no". And what I definitely don't want is applications responding to it – I want them to ignore it and use the WM_CHAR message only to get the character I typed, and respond to Crtl+Alt shortcuts only when Ctrl+Alt is pressed. (I think in most of the cases the developer isn't even aware of how the AltGr key works, because it doesn't play such an important role in the keyboard layout he/she uses, so ignoring it would be more or less the default behavior :))

    [Until somebody writes an app that intentionally sets a hotkey on AltGr+V and then people whose keyboard layouts don't have an AltGr say, "How do I invoke that hotkey?" -Raymond]
  22. Anonymous Coward says:

    @Raymond: ‘Until somebody writes an app that intentionally sets a hotkey on AltGr+V’

    The chances are extremely remote since those programmers actually using keyboard layouts with an AltGr have to use it themselves to enter special characters (and hence would find it annoying if an application did that, just like Alv) and are furthermore aware of the fact that the standard US layout doesn't have one, just like they're aware that Americans use the dot as a decimal separator.

    The reverse situation, everything from applications stealing AltGr to using dots instead of commas is a kind of tunnel vision that seems to be almost exclusive to American programmers.

    And even if it were to occur, an unavailable hot-key is generally far less annoying than an unavailable character, since applications need to be usable even when the user knows no hot-keys at all.

  23. Troy says:


    Well i've never used those signs in the letter keys but if i ever need to and a shortcut is in the way, replacing / remap the useless dollar ($) and pound (£) signs would do the trick ;)

    I spell out the sign instead euro instead of € and so on.

    I bet only spreadsheet hardons and bullshitter / scammers use those signs to appear more legit and "professional". The jokes on them for thinking that of course.

  24. Anonymous Coward says:

    Troy, the € sign is commonly used in Europe, and the same goes for ° (AltGr+:), and some language specific characters, like ¡ (AltGr+!), ¿ (AltGr+/), ß (AltGr+s), and so on, as well as special purpose characters like µ (AltGr+m). But in my experience people tend to prefer dead keys for things like ä, ó, ñ, è, and ç, perhaps because it's hard to remember under which keys all the vowels are hidden and usually only the € is actually printed on the keyboard.

  25. alv says:


    Wouldn't intentionally mapping a shortcut to the "new" AltGr fall into the same category as mapping it to the Windows key, making it obviously wrong? In contrast, a shortcut mapped to Ctrl+Alt could come from an application originally made for DOS in 1982 and later ported to Windows, keeping the original shortcuts to avoid re-training users.

  26. Anonymous Coward says:

    Erratum: ¡ is normally AltGr+1. I probably slipped up because of the fact that 1 and / are in a way mnemonic for ! and ? although AltGr+! is ¹ and AltGr+? doesn't seem to do anything. (Note: this is on a US international keyboard layout.)

  27. Joshua says:

    [Until somebody writes an app that intentionally sets a hotkey on AltGr+V and then people whose keyboard layouts don't have an AltGr say, "How do I invoke that hotkey?" -Raymond]

    There was a certain old Unix program that had AltGr+key do something different than Ctrl+Alt+key. This was actually possible on certain old Unix systems because the scan codes actually were different. Incidentally, we should be thanking Microsoft for restoring the AltGr key on US keyboards (it's the right Windows key: we just remap it). Since they are different scancodes again, said old Unix program works again. Not that there was any excuse for it in the first place. Unix had to deal with weird keyboard layouts long before Windows did.

  28. Christian says:

    Does anyone know why the old virtual server 2005 ActiveX control breaks ALT+GR if it is pressed once? Or if it is pressed, then maybe CTRL is permanently pressed, I don't remember the details. The rdp client used to have this bug, too: When I wanted to enter (ALTGR+ß) it always worked with ALT+GR+ß, but with ALTGR+ß it sometimes didn't register and I had to press it twice. I'm on a German keyboard.

  29. hacksoncode says:

    I think the complaint here is Ctrl+Alt shortcuts that are *global*, so their impact is not limited to an application that decides what the most appropriate keystroke functionality is for itself.

    [But the letter "N" is also global. -Raymond]
  30. David Walker says:

    Alv, are you disagreeing with Raymond when he says that AltGr *is* a new key with a new keycode, and that Ctrl+Alt is assigned as a shortcut FOR AltGr?

  31. Dan says:

    I want to comment on this: blogs.msdn.com/…/10293933.aspx

    Why can't the default handler for a button control handle tab key? Then there whouldn't be any need for IsDialogMessage().

    [That wouldn't help you tab out of edit controls or listview controls or X for any X != button. -Raymond]
  32. David Walker says:

    @David Walker:

    Yes. See 23 Apr 2012 11:05 AM.

  33. ender says:

    One of the more obnoxious programs that stole AltGr shortcuts was Delphi 6 – made it pretty much impossible to use with Slovenian keyboard layout until you changed an undocumented registry setting (Slovenian layout has |[]@{} on AltGr+QWFGVBN).

    And as for using €, I rarely use Excel, but use the character quite often – it's faster to type than EUR and it's easier to read.

    (and I see that comment posting still wasn't improved any)

  34. Medinoc says:

    I also remember a forum that used to steal Alt+1 for a link shortcut. Good luck typing a 'É' then…

  35. Anonymous Coward says:

    Joshua, you are wrong. The AltGr key still has a different scan code from the Alt key (which is why I suggested looking at WM_SYSKEYDOWN in a possible shim) and it's different from the right logo key. Most (non-laptop) keyboards have both.

    David Walker, neither Alv or Raymond say exactly what you say, and they agree on what the situation is, and only seem to disagree on what the situation should be. In particular Alv proposes treating AltGr differently from Ctrl+Alt, which Raymond seems to oppose.

    Ender, comment posting won't improve ever. The people who operate the blog system know about the issues, but don't care.

    As for Delphi 6… if I had to use it I guess I would actually go about and write that shim. Yes, writing shims is horrible, but there's only so much torture I can tolerate and a non-working AltGr key would be too much.

    [The people who run the blog system know about the issues and are trying to fix them. Indeed, they deployed yet another attempted fix just last week. So if you want to insult them, you should at least be accurate and accuse them of incompetence instead of apathy. -Raymond]
  36. Jason T. Miller says:

    Heavy clipboard users like myself might similarly ask "why are programmers allowed to use things like the IPv4 control in place of ordinary text boxes?" You know, the kind that support both copy and paste! This would also reduce the temptation to design "auto-advance" edit boxes that lose focus on keystrokes other than tab, frustrating for a number of reasons.

    One of the nicer things about OS X applications is that, for whatever reason, third-party Mac developers seem less prone to "superfluous" custom control creation, so, among other things, OS-level support for things like UI automation, dictionary look-up, and Emacs key bindings in edit controls actually work reasonably well.

Comments are closed.

Skip to main content