MapVirtualKeyEx function
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code. The function translates the codes using the input language and an input locale identifier.
Syntax
UINT WINAPI MapVirtualKeyEx( _In_ UINT uCode, _In_ UINT uMapType, _Inout_opt_ HKL dwhkl );
Parameters
- uCode [in]
-
Type: UINT
The virtual-key code or scan code for a key. How this value is interpreted depends on the value of the uMapType parameter.
Starting with Windows Vista, the high byte of the uCode value can contain either 0xe0 or 0xe1 to specify the extended scan code.
- uMapType [in]
-
Type: UINT
The translation to perform. The value of this parameter depends on the value of the uCode parameter.
- dwhkl [in, out, optional]
-
Type: HKL
Input locale identifier to use for translating the specified code. This parameter can be any input locale identifier previously returned by the LoadKeyboardLayout function.
Return value
Type: UINT
The return value is either a scan code, a virtual-key code, or a character value, depending on the value of uCode and uMapType. If there is no translation, the return value is zero.
Remarks
The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input.
An application can use MapVirtualKeyEx 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 get the scan code corresponding to the left or right instance of one of these keys by calling MapVirtualKeyEx 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 available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, MapVirtualKey, and MapVirtualKeyEx functions. For list complete table of virtual key codes, see Virtual Key Codes.
Requirements
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
MapVirtualKeyExW (Unicode) and MapVirtualKeyExA (ANSI) |
See also
- Reference
- GetAsyncKeyState
- GetKeyboardState
- GetKeyState
- LoadKeyboardLayout
- SetKeyboardState
- Conceptual
- Keyboard Input