by Michael S. Kaplan, published on 2006/07/21 03:16 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/07/21/673569.aspx
Chris was thinking about how keyboard layouts work on Windows, and suggested:
Windows allows a user to set up multiple keyboards within an input language, and switch between them either by a keyboard shortcut or by clicking an icon on the taskbar. However, when the keyboard layout is changed, the change is only applied to the current window.
This behaviour is extremely confusing to users, as the characters that appear as they type then vary from window to window. By default, using the keyboard shortcut or clicking the taskbar icon to select another keyboard, the new keyboard should be used in all windows.
If it is necessary to keep the old behaviour, this should be done via a (non-default) check-box on the "Language Bar" tab of the "Text Services and Input Languages" applet.
It is an interesting idea, and also a difficult one. The list of installed keyboards (which actually means the list of enabled keyboards) is a per user setting on a machine. And, as Chris mentioned, every language can have more than one keyboard attached to it.
So, let's say that I have English and Korean enabled, with multiple input methods on each:
If I look at the Language Bar, I have the option of choosing the language:
and then also the keyboard layout under the language once it is selected:
Thankfully, the selection mechanism is smart enough to remember the selection in each language. So that if I
It is smart enough to remember that I switched to that specific IME. This is as good thing.
Now we move to the complicated part -- the fact that actual, specific combination of language and layout is a per thread setting. This has been the design for a long time and it usually leads to two potentially non-intuitive behaviors:
Now that first point is longstanding behavior that is often relied on by people (including me!), and although it is not immediately intuitive it does kind of make sense, especially when one finds oneself e.g. typing a document in a particular language and not expecting that to lead to changes in one's email program....
The secone point is the one that Chris is talking about. Any time one changes the keyboard layout for a language, then isn't it often more likely that you would perhaps expect that switch to be applied to all other UI threads in the session that use this language?
Clearly there are exceptions here (plus there is a legacy expectation that some people may be used to), but that is also why Chris is suggesting some kind of configurable switch. I tend to agree with Chris that the change here is more likely to meet the intuitive expectations of customers, don't you?
This kind of change is complicated for someone to do themselves -- there would need to be a call to SetWindowsHookEx to inject a DLL into every thread to run code to check GetKeyboardLayout -- and if the languages (in the LOWORD) match and the device (in the HIWORD) do not then make a call to ActivateKeyboardLayout to make the switch.
But if you look at the Language Bar and the Text Services Framework, it already has a little something running in every thread, managing this information. So it is in a much better position to architect the kind of cross-thread, cross-process communication that might be required here.
Not an easy change, by any means. But an excellent feature request that is definitely worth considering for a future version of Windows. Good idea, Chris! :-)
This post brought to you by ђ (U+0452, a.k.a. CYRILLIC SMALL LETTER DJE)
# Mihai on 21 Jul 2006 5:38 AM:
# John Ingres on 21 Jul 2006 7:14 AM:
# Ben Cooke on 21 Jul 2006 11:33 AM:
# josh on 22 Jul 2006 2:32 AM:
# Michael S. Kaplan on 22 Jul 2006 3:42 AM:
# cnettel on 22 Jul 2006 9:26 AM:
# Michael S. Kaplan on 22 Jul 2006 1:32 PM:
# josh on 23 Jul 2006 4:30 AM:
# Michael S. Kaplan on 23 Jul 2006 7:48 AM:
# Chris on 26 Jul 2006 11:02 AM:
Nick Fagerlund on 27 Mar 2008 4:43 AM:
I just got bit by this misbehavior. I switched to the Dvorak keyboard since the last time I tried using Windows, and when my computer ended up in the shop, I ended up sharing an XP box with someone else. I thought I'd just flip the switch whenever it was my turn to use the thing, but I've apparently been spoiled rotten by Mac OS X.
Not only shouldn't assigning different keyboard layouts to every single window be the default, but I'm having a hard time imagining *any* situation where you'd want it to work that way. This is total madness.
YayWindows on 30 Jun 2011 5:26 PM:
And, five years and two versions of Windows later, the problem remains: if I am working with multiple languages in multiple windows, as I often am, then there is no way for me to predict what will happen when I press a key on my keyboard except to squint at a tiny icon down at the corner of the screen that indicates which layout is active for whichever window has the focus. Click into another window? All bets are off.
The only thing that's changed since 2006 is that, so far as I can tell, none of the third-pary programs people have written over the years to fix this bug work any more in Windows 7. Yay Windows.
Michael S. Kaplan on 30 Jun 2011 6:07 PM:
It still remains too much of a corner case to interest the owners of Cicero or User to or the Window Manager to jump in and fix the issue.
Not sure what programs you're talking about or their methods of action, but I assume none of them were trying to fix it by supported means?
go to newer or older post, or back to index or month or day