Keyboard Input

The keyboard is an important means of user input on many Windows CE-based devices. Windows CE maintains a device-independent keyboard model that enables it to support a variety of keyboards. Because most Windows CE-based devices have built-in keyboards, the OEM usually determines the keyboard layout for a specified Windows CE-based device.

At the lowest level, each key on the keyboard generates a scan code when it is pressed and released. The scan code is a hardware-dependent number that identifies the key. Unlike Windows-based desktop platforms, Windows CE has no standard set of window keyboard scan codes. For this reason, you should not depend on scan code values unless your application will only run on platforms for which you know the scan code values.

The keyboard driver maps each scan code to a virtual key code. The virtual key code is a hardware independent number that identifies the key. Because keyboard layouts vary from language to language, Windows CE offers only the core set of virtual key codes that are found on all keyboards. This core set includes the Latin letters, numbers, and a few critical other keys, such as the function and arrow keys. Keys not included in the core set also have virtual key code assignments, but their values vary from one keyboard layout to the next. Therefore, you should only depend on the virtual key codes that are in the core set.

In addition to mapping, the keyboard driver determines which characters the virtual key generates. A single virtual key generates different characters depending on the state of other keys, such as the SHIFT and CAPS LOCK keys. Do not confuse virtual key codes with characters. Although many of the virtual key codes have the same numerical value as one of the characters that the key generates, the virtual key code and the character are two different things. For example, the same virtual key generates the uppercase "A" character and the lowercase "a" character.