GetAsyncKeyState() after system("PAUSE")

I am looking for a way to wait for either an Escape or Return keypress and ignore all others. Escape should break out of the loop, and return should print, take a user input, then continue the loop.

Escape breaks the loop as expected. The problem I am having is that any key that isn't Escape will take me into the else if clause, but it should only do that for Return. I am wondering if going into the `else if` block has something to do with System("PAUSE") or hitting enter after taking a user input.

Why am I going into the else if block unexpectedly, and what would be a better way of pausing until one of these keys is pressed?
It is nonsensical without the code to see
It looks like it needs to be used something like this:

1
2
3
4
5
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
    ; // escape key is down

if (GetAsyncKeyState(VK_RETURN) & 0x8000)
    ; // return key is down 

I forget @dutch is psychic!
It was only virtually nonsensical. :-)

Also, I remember from a past question that it's a little weird to use since the low bit should be ignored (from what I can make of the MS docs).
Topic archived. No new replies allowed.