input without pressing enter python

Solutions on MaxInterview for input without pressing enter python by the best coders in the world

showing results for - "input without pressing enter python"
Helena
21 Mar 2016
1import tty, sys, termios
2
3filedescriptors = termios.tcgetattr(sys.stdin)
4tty.setcbreak(sys.stdin)
5x = 0
6while 1:
7  x=sys.stdin.read(1)[0]
8  print("You pressed", x)
9  if x == "r":
10    print("If condition is met")
11termios.tcsetattr(sys.stdin, termios.TCSADRAIN,filedescriptors)