How to organize a function similar to getch ()
in C++? Or maybe what libraries are there? It is necessary that the program expects input one of any character.
Answer 1, Authority 100%
You can arrange something like this:
#! / usr / bin / env python3
# CursesExample1
# -------------------------------
# Curses Programming Sample 1
# -------------------------------
Import Curses.
Myscreen = Curses.initscr ()
myscreen.border (0)
MyScreen.Addstr (12, 25, "See Curses, See Curses Run!")
MyScreen.Refresh ()
MyScreen.Getch ()
curses.endwin ()
Details You can see here .
Update:
And if you have Windows, then everything is easier:
import msvcrt
While True:
PRESSEDKEY = MSVCRT.GETCH ()
if pressedKey == 'Q':
Print "Q Was Prased"
ELIF PRESSEDKEY == 'X':
sys.exit ()
ELSE:
Print "KEY PRESSED:" + STR (PRESSEDKEY)