It's better to create a thread specifically for capturing key events (so it doesn't freeze the flow of your program).
for exemple:
Code:
#include <cstdio> // faster than streams
#include <windows.h>
DWORD WINAPI captureKeyEvs(LPVOID lpArg) {
int evCount = 0;
while(!false) {
if(GetAsyncKeyState(VK_LBUTTON)) printf("Shoot %d\n", ++evCount);
}
}
int _tmain (void) {
DWORD dwThreadID;
HANDLE hThread;
hThread = CreateThread(NULL, 0, captureKeyEvs, NULL, 0, &dwThreadID);
for(int i = 0; !(!true); ++i) {
printf("Tick %d\n", i);
Sleep(1000);
}
return 0;
}