Wait for release key without blocking

Viewed 25

I have this function that work and let me known if a key is released:

bool KeyReleased(int vKey)
{
    if (GetAsyncKeyState(vKey) & 0x8000)
    {
        while (GetAsyncKeyState(vKey) & 0x8000)
        {
        
        }
        return true;
    }

    return false;
}

I use it inside a game, when I press a key the game stop until I release the key.

I ask if there is a way to write something inside the while that reduce the stopping in the game or other solutions to solve the problem.

Thanks !

0 Answers
Related