views:

30

answers:

2

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?

+1  A: 

You can use GetKeyState() to determine key state of by providing virtual key code. See also: GetKeyboardState().

Donotalo
A: 

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[].

Plumenator