I believe the best way would be to use asynchronous key checking using the function:
Probably not the best way to do it, as you'll need to have a loop sitting in the background checking the state every few milliseconds. I'd suggest putting Sleep function in there so the program doesn't hog the cpu.
#define KEY_DOWN(vk_code) ((GetAsyncKeyState((vk_code))&0x8000 ? 1:0))
so you might do something like this:
or something like that
// do stuff!
-hope that helps