Search code examples
windowswm-syscommand

WM_SYSKEYDOWN not updating


I tried something with WM_SYSKEYDOWN, and WM_SYSKEYUP for Keyboard-Input.

Here is the significant codepart.

        case WM_SYSKEYDOWN:
            if (wParam == VK_MENU)      // VK_MENU = 18 = alt keys
            {
                if (!(lParam & (1 << 30)))
                {
                    std::cout << "Pressed left alt key" << std::endl;
                }   
            };
            break;

        case WM_SYSKEYUP:
            if (wParam == VK_MENU)      // VK_MENU = 18 = alt keys
            {
                        std::cout << "Released left alt key" << std::endl;
            };
            break;

I tried to print one string one time if I pressed the button, and printing the other string on releasing the key.

Releasing works, but pressing responses just one time each 2 presses.

if (!(lParam & (1 << 30)))

This line should interrupt frequently posting the string again.

I don't get it why... , but I hope do.

Thanks in advance!


Solution

  • I used no this function I found.

    if (GetAsyncKeyState(VK_LSHIFT) & 0x8000)
    {
    // Button pressed!
    }
    

    That works well :D