MSDN Library

Keyboard Layout Generator Tool

Other versions of this page are also available for the following:
Windows Mobile Not SupportedWindows Embedded CE Supported

The Keyboard Layout Generator tool (Kbdgen.exe) produces input language and device layout source files from a Windows XP keyboard layout DLL.

These source files can be placed in the same or separate DLLs as long as the registry entries are set appropriately. You must expose the input language and device layout entry points: IL_XXXXXXXX and PS2_AT_XXXXXXXX entry points.

         <DLL Name> [-v] [-o <Output File Prefix>] [-i <Input Locale>]

< DLL Name>

Name of the Windows XP keyboard layout DLL. Kbdgen will attempt to load this file from the current directory. If this fails, Kbdgen will then attempt to load the file from the Windows system directory. The keyboard layouts that come with Windows XP can be found in the registry under [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts].


Optional. Specifies verbose output.

-o <Output File Prefix>

Optional. Specifies that Kbdgen must write output to a file instead of writing to the console, and defines what prefix to use for the output files. By default, Kbdgen places the output files in the current directory.

-i <Input Locale>

Optional. Specifies that Kbdgen must use the given input locale for function names and registry entries. If it is not specified, XXXXXXXX is used and the user is responsible for changing the name in the files.

The following code example shows how to use Kbdgen on the Kbddv.dll file in the current directory. Once Kbdgen locates the file, it generates Dvorakil.cpp, Dvoraldl.cpp, and Dvorak.reg, using the input locale 00010409.

kbdgen kbddv.dll –o dvorak –i 00010409

Kbdgen extracts keyboard layout information for any PS/2 keyboard layout supported by Windows XP.

The following table shows the files that Kbdgen generates if you specify the -o parameter. If you have not specified the -o parameter, the output is written to the console.

File name Description

<Output File Prefix>IL.cpp

Input language source file.

<Output File Prefix>DL.cpp

Device layout source file.

<Output File Prefix>.reg

Sample registry entries that may be used for this layout.

After these files are generated, you must perform the following tasks for each file type.

File type Tasks

Input language source file

The default keyboard layout uses the right and left Shift, Control, and Alt keys, and the CAPS LOCK, NUM LOCK, and SCROLL LOCK keys as shift or toggle keys.

If your keyboard layout uses different shift or toggle keys, you must add the appropriate conversion tables, VkToToggledStateTable, VkToShiftStateTable, or both, to the generated Input Language file.

If the input locale is not specified, fill in the XXXX in the IL_0000XXXX function name with the proper input language identifier.

For example, the Japanese input language file, which demonstrates a case where the Kana toggle key is added, is at %_WINCEROOT%\Public\Common\OAK\Drivers\Keybd\Inputlangs\0411\IL_0411.cpp.

Duplicate entries have been removed from the VKeyToXTScanCodeTable array, as described in comments and in console output. Verify that the proper XT scan code is used for these virtual keys.

Device layout source file

This file includes remapping for the numeric keypad. When building this file, be sure the keypad remapping library is included in your run-time image. This library is at %_COMMONOAKROOT%\lib\%_CPUINDPATH%\NumPadRmp.lib.

If the input locale is not specified, substitute the proper input locale identifier for the XXXXXXXX in the PS2_AT_XXXXXXXXfunction name.

Sample registry file

Fill in all the fields in the registry entries.

Choose a Preload index that will not conflict with others installed on the system.

Community Additions

© 2016 Microsoft