Unbuffered Keyboard Input

I am just wondering different ways of getting unbuffered keyboard input. I have some program ideas that, even though they're based on the command line, would be improved if the user didn't have to press enter. (Is it even possible to have unbuffered input using just the console?)

For example, I have thought it would be an interesting practice to make a command line 'tetris'.
Last edited on
dont't know if you're looking for this but:
include <conio.h>

and use kbhit() (in msvc++ _kbhit()) to check if a key is pressed
and then use getch() (or _getch()) to get the pressed key.
i've already written a commandline tetris and i used these input-function
1
2
3
4
5
6
7
8
9
char getinput()
{
    if (_kbhit())
    {
        _getch(); // edit : if you want to check the arrow-keys you must call getch twice because special-keys have two values
        return _getch();
    }
    return 0; // if no key is pressed
}

Last edited on
Thanks a lot that's awesome.
Topic archived. No new replies allowed.