You don't even have to do that. Just use GetChar() in your loop, as it doesn't wait like WaitKey does. If it returns anything other than 0, a key has been pressed. It returns ASCII codes, not key codes, though just something to be aware of if you need to use it.