April 23rd, 2012

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

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.