1 # From http://code.activestate.com/recipes/134892/
2 # "getch()-like unbuffered character reading from stdin
3 # on both Windows and Unix (Python recipe)"
6 """Gets a single character from standard input. Does not echo to the
10 self.impl = _GetchWindows()
12 self.impl = _GetchUnix()
14 def __call__(self): return self.impl()
22 import sys, tty, termios
23 fd = sys.stdin.fileno()
24 old_settings = termios.tcgetattr(fd)
26 tty.setraw(sys.stdin.fileno())
27 ch = sys.stdin.read(1)
29 termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)