Switching between keyboard layouts involves changing the tables that determine which characters result when you press the keys. The tables exist independently from physical keyboards, though some keyboards, such as Japanese keyboards, have additional keys with special functions. On Windows, you don't have to change your hardware to change your input language. You can type Japanese text using a standard United States (US) keyboard, even without the additional keys. The keyboard templates in Appendix Q show the characters produced by each of the keyboard layouts that Windows 95 supports.
Language/Layout Pairs
Because Windows 95 gives the user the ability to type multiple languages using multiple keyboard layouts, the system needs to know which keyboard layout should be active for a particular language. It does this by keeping track of all languages the user has installed and which keyboard layout the user has associated with each language. These associations are called language/layout pairs, or input languages.
When the user installs Windows 95, the setup program automatically installs a default language/layout pair that corresponds to the language edition of the system. For example, if the user installs the French edition of Windows 95, the setup program creates a list of languages containing only one entry (Standard French) and pairs it with the French keyboard. However, the system allows the user to create alternative pairs as long as the selected keyboard layout can produce the characters used by the language. Thus, a user running a custom setup could conceivably assign the Arabic, Canadian, Turkish, or US keyboard layout to the French language. The user can add or modify language/layout pairs at any time using the keyboard icon in Control Panel. (See Figures 6-1 and 6-2.)
Figure 6-1 Standard German has been added to the list of input language choices using the Windows 95 Properties for Keyboard dialog box. The user can change the keyboard layout associated with the input language at any time by clicking the Properties button.
Figure 6-2 The Language Properties dialog box allows the user to change the keyboard layout that is paired with a given language.
Windows 95 tracks language/layout pairs using a new variable type called an input language handle, often referred to as an HKL, which is illustrated below.
The low word of the handle is a language ID, and the high word is a handle to a keyboard layout. You can zero-extend the language ID to form the corresponding locale ID for tagging text and calling NLSAPI functions. The API functions that take an HKL as a parameter are listed in the following table:
Keyboard-Related API Function | Description |
GetKeyboardLayout | Returns the active language/layout pair |
GetKeyboardLayoutList | Returns a list of installed language/layout pairs |
GetKeyboardLayoutName | Returns the name of the active keyboardlayout |
LoadKeyboardLayout | Loads a new keyboard layout into thesystem |
UnloadKeyboardLayout | Unloads a keyboard layout; cannot unload the system default |
ActivateKeyboardLayout | Changes the active language/layout pair |