Skip to content

Instantly share code, notes, and snippets.

@payne92
payne92 / gist:11090057
Created April 19, 2014 16:49
getch() function to read single char from stdin, w/o waiting for newline (Windows and Unix)
# If Windows getch() available, use that. If not, use a
# Unix version.
try:
import msvcrt
getch = msvcrt.getch
except:
import sys, tty, termios
def _unix_getch():
"""Get a single character from stdin, Unix version"""