0
How do I read keyboard input without waiting for the user to press Enter?
4 Answers
+ 2
That almost possible only in a GUI environment, not really in CLI context (there's some specific tricks to workaround with some platforms, but nothing really os agnostic and/or simple)...
... and not at all in sololearn code playground, of course.
+ 3
Actually it is possible, but you'll have to be creative on it.
The first option would be to simulate keypress using a library like pyautotui, and set a timer that will press enter key on timeout. The second option would be to use the threading library and create a timed thread.
+ 2
A way to do it is to use the ncurses module (standard library) wich is the binding of ncurses c-library (handling cross-platform/terminal advanced terminal output): there's a mode where you can listen for key events ;)
https://en.m.wikipedia.org/wiki/Ncurses
https://docs.python.org/3/library/curses.html
https://docs.python.org/3/howto/curses.html