Windows 3.1 Device Drivers (ddag31qh.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
ANSI Characters
                                                     Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
Windows and Windows applications call the ToAscii function to translate
virtual-key codes to ANSI characters. The keyboard driver translate these
key codes by checking the state of the virtual-shift keys (such as the
VK_SHIFT, VK_CONTROL, and VK_MENU) and mapping the virtual-key code and
shift state to the appropriate character. For example, on most U.S.
keyboards if the VK_SHIFT key is up, the VK_2 virtual key code maps to the
number 2 (ANSI 50); if VK_SHIFT is down, VK_2 maps to the at sign (@) (ANSI
64). For foreign-language keyboards, the keyboard also checks for a
previously typed dead key before translating the virtual-key code.
 
Windows passes the address of the key-state array to the ToAscii function,
giving the keyboard driver access to the current state of all virtual keys
including the shift keys. The key-state array also contains the shift state
of the mouse buttons (that is, the corresponding virtual-key codes
VK_LBUTTON, VK_RBUTTON, VK_CANCEL, and VK_MBUTTON).
 
The keyboard driver must provide translation tables to map virtual keys to
ANSI characters. Since the meaning of a virtual key depends on the state of
the shift keys, the driver should provide tables for each possible shift-key
combination (for example, no shift key, VK_SHIFT, VK_CONTROL, and VK_MENU
and VK_CONTROL combined). Windows does not require that all virtual keys map
to ANSI characters for all shift-key combinations. Therefore, not all
translation tables need to map the complete virtual-key set.
 
The keyboard type and language also affects the translation of virtual-key
codes to ANSI characters. The keyboard driver must adapt its translation
tables for a specific-language by loading translation tables from the
corresponding language-specific library.
 
 
                                      ♦