MediatedCommunications / WindowsInput

Capture and Simulate Keyboard and Mouse Input
MIT License
115 stars 17 forks source link

Keyboard state seems to be stuck on Toggled. #17

Open Martenfur opened 3 years ago

Martenfur commented 3 years ago

I got this code:

        var state = KeyboardState.GetAsyncKeyState(KeyCode.LShift);

        if (state != KeyboardKeyState.Default)
        {
            await Simulate.Events().Release(KeyCode.LShift).Invoke();
        }
        else
        {
            await Simulate.Events().Hold(KeyCode.LShift).Invoke();
        }

It is supposed to toggle the Shift key. And it does work - once. After the first press state seems to be Toggled no matter what I do. Even restarting the program keeps the key state. Only rebooting resets it back.