VkKeyScan

2.x

  UINT VkKeyScan(uChar)    
  UINT uChar; /* character to translate, */  

The VkKeyScan function translates a Windows character to the corresponding virtual-key code and shift state for the current keyboard.

Parameters

uChar

Specifies the character to be translated to a virtual-key code.

Return Value

The return value is the virtual-key code and shift state, if the function is successful. The low-order byte contains the virtual-key code; the high-order byte contains the shift state, which can be one of the following:

Value Meaning

1 Character is shifted.
2 Character is a control character.
3–5 Shift-key combination that is not used for characters.
6 Character is generated by the CTRL+ALT key combination.
7 Character is generated by the SHIFT+CTRL+ALT key combination.

If no key is found that translates to the passed Windows code, the return value is –1.

Comments

Translations for the numeric keypad (VK_NUMPAD0 through VK_DIVIDE) are ignored. This function is intended to force a translation for the main keyboard only.

Applications that send characters by using the WM_KEYUP and WM_KEYDOWN messages use this function.

See Also

OemKeyScan