Reputation: 1682
I looked at MapVirtualKey() and ToAscii().
MapVirtualKey() gives me only the unshifted character. ToAscii() only works for vk codes that translate to ASCII values.
I need to detect for example, "Ctrl + Shift + 3" as Ctrl active, Shift active and '#'.
Any clues?
Upvotes: 2
Views: 5218
Reputation: 1682
This is how I finally did it:
case WM_KEYDOWN:
GetKeyboardState(kbs);
if(kbs[VK_CONTROL] & 0x00000080)
{
kbs[VK_CONTROL] &= 0x0000007f;
::ToAscii(p_wParam, ::MapVirtualKey(p_wParam, MAPVK_VK_TO_VSC), kbs, ch, 0);
kbs[VK_CONTROL] |= 0x00000080;
}
else
::ToAscii(p_wParam, ::MapVirtualKey(p_wParam, MAPVK_VK_TO_VSC), kbs, ch, 0);
Then I get the states of all the modifier keys from kbs[].
Upvotes: 4
Reputation: 13025
You can use GetKeyState() to determine key state of by providing virtual key code. See also: GetKeyboardState().
Upvotes: 2