1

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!

DotBlack
  • 38
  • 1
  • 6
  • WM_SYSKEYDOWN is reserved to keystrokes that *combine* the ALT key with an another key. Or F10. A distinction that is well past its original intended usefulness, whatever it might have been. The sane way to go about it is to treat them the same way as WM_KEYDOWN. – Hans Passant Jul 15 '16 at 16:36
  • So, that means there is a way to indicate which "alt" key is which key. Left or right one? I didn't find a way to do that. The left alt key just doesn't give me a index at WPARAM by typing on it. So i tried that methode.. (Note: the right alt key gives me that index I need) – DotBlack Jul 15 '16 at 16:44

1 Answers1

0

I used no this function I found.

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

That works well :D

DotBlack
  • 38
  • 1
  • 6
  • 1
    It just tells you that the key is down, it doesn't tell you that it was just pressed. Okay in a game loop, deadly in a standard winapi program. – Hans Passant Jul 15 '16 at 22:25
  • I'm just checking 6 keys with that each frame. I don't think that's a problem. I didn't find a better solution either. – DotBlack Jul 17 '16 at 12:09