How to get active user input?

When launching games, pressing the arrow key doesn't require a follow up keypress by pressing enter. It just moves me without waiting for me to press enter or anything like that.

How do you get active user input, the kind that you would evaluate with "while(keyIsPressed)" or something of the sort.

1
2
3
4
5
int main()
{
    char input;
    std::cin >> input;
}

In the above code, before input is defined as a character, I have to press enter. How would I make it automatically take the input without waiting for me to press enter?
Last edited on
Yes you can, but the answer is specific to your OS (and perhaps even your compiler).

Say what you have if you want a specific answer.
I'm just using onlinegdb.com right now, chromebook. Nothing too serious.
Is it only doable on serious compilers like microsoft visual?
Last edited on
https://www.onlinegdb.com/faq
Any third-party library do you support?
We support following third-party libraries.
Language Library
c/c++ ncurses,lapack
c++ boost

ncurses allows you to write programs which don't wait for "enter".
Though how usable that is over a web interface, I've no idea.

Topic archived. No new replies allowed.