Administration and deployment (File menu)
The File menu is the start- and end-point for all keyboard layout modifications. Commands from this menu occupy prominent places in the KbdEdit usage roadmap, which generally looks like this:
Keyboard layout definitions under Windows
To better understand the purpose of KbdEdit's File menu commands, and why they work the way they do, it would be useful to understand how keyboard layouts are organized - both logically and physically - in current Windows versions. It is possible to use KbdEdit just fine without delving into the fine details of keyboard layout structure, but a tech-savvy user would probably find the following (heavily technical) information useful.
Layout definitions are saved in Layout DLL files. These files reside in the Windows's standard System32 directory. On most Windows installations, the actual path to this directory is C:\Windows\System32 or C:\WinNT\System32 . The names of all layout files begin with kbd, and have the standard .dll extension.
KbdEdit imposes an additional rule on the layout files it creates: their names always begin with KbdEdit instead of generic "kbd", which makes them easy to locate in the overcrowded System32 directory.
The Layout DLL files are saved in the so-called "portable executable" (PE) file format - they have essentially the same basic structure as any other executable DLL or EXE file on a Windows system. The data structures specific to keyboard layouts are "injected" into the DLL file, and are accessed through a single "entry point".
This fact alone explains why there are so few general-purpose Windows keyboard editors in the market: it is extremely difficult to create such a tool that would be stand-alone, i.e. not dependent on other component(s) for the generation of DLL files. Building the keyboard-editing part, while certainly not trivial, is relatively easy compared to the effort needed to create a fully-fledged PE file, which is normally created from source files using tools known as "compiler" and "linker" - both extremely complex pieces of software.
KLID - a unique layout identifier
A layout is uniquely identified on the system by its KLID - short for Keyboard Layout IDentifier. KLIDs are 32-bit numeric values represented as 8 hexadecimal digits.
The lower 4 digits of a KLID represent its 16-bit locale identifier (LCID). The notion of a locale is somewhat complex, but for the purpose of keyboard layout editing it is enough to say that a locale represents a variant of a language as spoken/written in a well defined geographic area.
The list of LCIDs is standardized, and constantly growing as support for new locales is being added to Windows. To see the list of locales supported by current version of KbdEdit, take a look at the Register as combo on the Save As dialog. For example, English as the most ubiquitous language is represented by several locales: 0409 for US English, 0809 for the English spoken in the UK, 0C09 for Australian English and so on. The languages with a relatively small number of speakers have only one locale, like Hungarian whose LCID is 040E.
Since the locale part occupies only lower half of a KLID, the remaining 16 bits are used to disambiguate between different layouts supporting the same locale. Windows does not impose strict rules on the contents of this part of a KLID. KbdEdit takes advantage of this flexibility by setting the highest KLID digit to B for all custom layouts it creates, which makes them easy to locate in the list of installed layouts.
For example, the standard "US English" keyboard layout's KLID is 00000409, whereas the variant of US English keyboard known as "US Dvorak" has a KLID of 00010409. If you create your customized version of "US English", its KbdEdit-generated KLID would look something like B00X0409. The exact value for "X" depends on how many other "US English" layouts already exist, e.g. the first such layout would have a KLID value of B0010409.
Placing a layout DLL file into the System32 directory is just the beginning. For a keyboard layout to be visible to Windows, it should also be properly registered. The list of registered layouts is stored in the registry database under the key HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts.
Each layout is represented as a sub-key named after the layout's KLID. The registry layout list thus consists of a long succession of keys with cryptic numeric names like 00000409, 00000418, 00010409 etc. Each sub-key contains data values detailing the layout attributes, most notably the layout DLL file name (entry "Layout Id") and layout's descriptive name ("Layout text").
One DLL file can be used by several layouts, which is perfectly normal and not that uncommon. This is usually the case of one physical layout being used for different locales covering similar languages, or one language in different geographic zones. For instance, a standard Windows layout file KBDCR.DLL is used by three distinct layouts: Croatian (KLID 0000041a), Bosnian (0000141a) and Slovenian (00000424).
As custom layouts are created and deleted, it would be extremely difficult to create and maintain new KLID entries by hand. Whenever a new custom layout is created, KbdEdit automatically allocates a unique KLID key corresponding to the layout's locale, creates the KLID-named registration key, and fills it with appropriate data values. This is basically what happens when you click OK in the Save As or Register Layout DLL file dialog.
Exception: Japanese and Korean layouts
The Japanese and Korean layouts are a notable exception to the above described method of registration: they do not give a unique KLID to each layout DLL file. Instead, a KLID is only assigned to the two "stub" layout files KBDJPN.DLL and KBDKOR.DLL, and the actual layout file to use is defined via a special registry setting under HKLM\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters. The Special NLS functions manual page has more details.
Language bar and its list
The list of all installed layouts can be very long - in Windows Vista there are well over 150 standard keyboard layouts covering all supported languages and locales. On the other hand, in everyday work you would typically need no more than couple of layouts, and a means to quickly switch between them. This problem is solved by a standard Windows component known as the Language Bar.
In its default "minimized" state, Language Bar appears as a small button on the taskbar displaying the current layout's two-letter mnemonic (e.g. EN for of English, FR for French etc). It can also be detached from the taskbar and shown as a small floating window - this is done by choosing "Restore the Language bar" from its right-click popup menu.
Language Bar manages a user-defined list of layouts, which can be quickly cycled through using the Alt+Shift global shortcut. The active layout can also be chosen from a list which opens up when the Language bar button is left-clicked.
The standard way to edit the language bar list is Windows standard Text Services and Input Languages dialog, which is accessed through Control Panel -> Regional and Language Options -> Languages -> Details ... , or by choosing Settings... from the Language bar right-click popup menu. KbdEdit supplies an alternative method: its own Language bar list editor offers a somewhat richer functionality and facilitates the integration of custom KbdEdit-generated layouts.
Unlike the list of all installed layouts, which is unique system-wide, the Language bar list is defined separately for each user. If you are curious you can see its contents in the registry database under the HKCU\Keyboard Layout\Preload key. Also important is the list of layout substitutes at HKCU\Keyboard Layout\Substitutes, which comes into play if a layout is put into the list under a locale different than its own "native" locale.
Copyright © KbdSoft 2007-2022