Using GetKeyState, I can do some task when a key is pressed. However, if I have if (GetKeyState(VK_UP) & 0x80), it returns true the entire time the key is being held.
How do I handle this if I just want this to be true the exact moment the key is pressed (so the contents of the if statement don’t run several times)?
You can use a
bool flag = falseand use it like this: