Reply to thread

Running the code below and pressing a key once results in two separate keyboard events with the output being


1

1


Kindly advise Thank You Cheerios


#include <iostream>

#include <cassert>

#include <windows.h>


void keyboard(HANDLE hstd_input)

{

    INPUT_RECORD input_record;

    DWORD nevents = 0;

    BOOL ok = ReadConsoleInput(hstd_input, &input_record, 1, &nevents);

    assert(ok);

    std::wcout << nevents << std::endl;

}


int main()

{

    HANDLE hstd_input = GetStdHandle(STD_INPUT_HANDLE);

    keyboard(hstd_input);

    keyboard(hstd_input);

}


Continue reading...


Back
Top