How to handle keyboard input in a non-blocking way without using threads in C++? [duplicate]

  c++, istream, keyboard-input, macos

I am trying to create a little snake game and I came quickly to a solution using threads to render and get keyboard inputs from the user.

But I was wondering if there is a way to get recently entered keyboard’s inputs in a non-blocking way and by not using any thread.
This in the goal to make this little rookie game in a way that only use the main thread.
There is no more reason than the challenge and curiosity about how keyboard’s inputs are treated by our computers.

I only have my young IT culture that reminds me about possibility for hackers to use input buffers to execute commands on computers. So I was wondering if computers bufferize all tips we do on our keyboard and if we can get it later.

Thanks for answers !


Source: Windows Questions C++