VkKeyScanExA function (winuser.h)
Translates a character to the corresponding virtual-key code and shift state. The function translates the character using the input language and physical keyboard layout identified by the input locale identifier.
Syntax
SHORT VkKeyScanExA(
[in] CHAR ch,
[in] HKL dwhkl
);
Parameters
[in] ch
Type: TCHAR
The character to be translated into a virtual-key code.
[in] dwhkl
Type: HKL
Input locale identifier used to translate the character. This parameter can be any input locale identifier previously returned by the LoadKeyboardLayout function.
Return value
Type: SHORT
If the function succeeds, the low-order byte of the return value contains the virtual-key code and the high-order byte contains the shift state, which can be a combination of the following flag bits.
Return value | Description |
---|---|
|
Either SHIFT key is pressed. |
|
Either CTRL key is pressed. |
|
Either ALT key is pressed. |
|
The Hankaku key is pressed |
|
Reserved (defined by the keyboard layout driver). |
|
Reserved (defined by the keyboard layout driver). |
If the function finds no key that translates to the passed character code, both the low-order and high-order bytes contain –1.
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.
For keyboard layouts that use the right-hand ALT key as a shift key (for example, the French keyboard layout), the shift state is represented by the value 6, because the right-hand ALT key is converted internally into CTRL+ALT.
Translations for the numeric keypad (VK_NUMPAD0 through VK_DIVIDE) are ignored. This function is intended to translate characters into keystrokes from the main keyboard section only. For example, the character "7" is translated into VK_7, not VK_NUMPAD7.
VkKeyScanEx is used by applications that send characters by using the WM_KEYUP and WM_KEYDOWN messages.
Note
The winuser.h header defines VkKeyScanEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |