UINT MapVirtualKey(uCode, fuMapType) | |||||
UINT uCode; | /* virtual-key code or scan code | */ | |||
UINT fuMapType; | /* translation to perform | */ |
The MapVirtualKey function translates (maps) a virtual-key code into a scan code or ASCII value, or translates a scan code into a virtual-key code.
uCode
Specifies the virtual-key code or scan code for a key. How this value is interpreted depends on the value of the fuMapType parameter.
fuMapType
Specifies the translation to perform. If this parameter is 0, the uCode parameter specifies a virtual-key code and is translated into its corresponding scan code. If fuMapType is 1, uCode is a scan code and is translated to a virtual-key code. If fuMapType is 2, uCode is a virtual-key code and is translated to an unshifted character value. Other values are reserved.
The return value depends on the value of the uCode and fuMapType parameters. For more information, see the description of the fuMapType parameter.
The MapVirtualKey function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set).
An application can use MapVirtualKeyCode to translate scan codes to the virtual key code constants VK_SHIFT, VK_CONTROL and VK_MENU, and vice versa. These translations do not distinguish between the left and right instances of the SHIFT, CTRL, or ALT keys. An application can obtain the scan code corresponding to the left or right instance of one of these keys by calling MapVirtualKey with uCode set to one of the following virtual-key code constants:
VK_LSHIFT | VK_RSHIFT |
VK_LCONTROL | VK_RCONTROL |
VK_LMENU | VK_RMENU |
These left- and right-distinguishing constants are only available to an application through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
GetAsyncKeyState, GetKeyboardState, GetKeyState, SetKeyboardState