Created
June 27, 2017 18:59
-
-
Save EdwardBetts/b4328d6ce0240059cb649954b1f2803c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getch(): | |
fd = sys.stdin.fileno() | |
old_settings = termios.tcgetattr(fd) | |
try: | |
tty.setraw(fd) | |
ch = sys.stdin.read(1) | |
except KeyboardInterrupt: | |
raise | |
finally: | |
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) | |
return ch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment