Windows 10 with latest updates installed on a Dell XPS13. US keyboard layout and US locale selected (not international). Still a call to kbhit() or _kbhit() with specific characters such as ", ~, % does not return the key hit, at least mot until a certain amount of time (~1second) and a second character has been hit. I try to use kbhit() because I need a non-waiting function. How can I detect correctly a keyboard hit on " or % with a single keystroke? In Linux using a timed-out select() on stdin works great, but doesn't seem to be OK with Windows.
Thanks, -Patrick
I finally found a solution that fits my needs and fixes the issues I have with
kbhit(); code below; I hope it helps others too.– Patrick
It is also possible to call
ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &buf, 1, &len);rather thanFlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));in the code above, but for some unknown reason, it doesn't seem to reply/react as quickly and some character are missed when typing at the keyboard.