#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main() {
do {
GetKeyState(VK_SPACE) < 0 ? printf("Space Pressed!\n") : system("cls");
} while (GetKeyState(VK_ESCAPE) >= 0 ? TRUE : MessageBox(NULL, L"Message", L"Title", MB_OK | MB_SETFOREGROUND));
return EXIT_SUCCESS;
}
Почему … GetKeyState() не считывает состояние клавиши?
The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.
If the function fails, the return value is zero.