#include <stdio.h>#include <stdlib.h>#include <windows.h>#define OK -32767/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) { int tecla= 70; int tep; do{ if(tep= GetAsyncKeyState(tecla)==OK){ //si pulsa una tecla printf("%d\n", tep); } }while(1<2); return 0;}
If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState