Whichs keys are down, which are up.

Whichs keys are down, which are up.

GetKeyState

See version :

Pas de dépendances

Download :

#include <stdio.h>
#include <windows.h>

void ShowConsoleCursor(int showFlag)
{
    HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO     cursorInfo;
    GetConsoleCursorInfo(out, &cursorInfo);
    cursorInfo.bVisible = showFlag; // set the cursor visibility
    SetConsoleCursorInfo(out, &cursorInfo);
}

int main()
{
    system("mode con cols=300 lines=5");
    ShowConsoleCursor(0);
    while (1)
    {
        unsigned char c;
        for (c = 0; c < 255; c++)
        {
            if (GetKeyState(c) & 0x8000)
                printf("1");
            else
                printf("0");
        }
        printf("\r");
    }
    return 0;
}




Explanations

No explanations yet.