How can I detect if a key is currently being pressed down?
It doesn't have to be multi-platform.
It only needs to work on Windows.
I'm using Bloodshed Dev-C++ if it makes any difference.
I've tried using getch(), but it waits for a key press, rather than checking if the key is pressed down at the moment.
Alternatively, checking what the last key to be pressed down was would work in my situation too.
Code:
while(1)
{
if(is key "x" being pressed down? or alternatively: was "x" the last key to be pressed?)
{
// do something
}
// do something else / continue looping
// regardless of wether or not the key is pressed,
// without waiting for any input
}
Would be nice if someone could throw in a code example.
Thanks in advance.