Created
October 2, 2019 20:48
-
-
Save IdlePhysicist/f5549d0cb7de0a13aae1469879f8e7e2 to your computer and use it in GitHub Desktop.
A simple python script for *NIX to wait for terminal input.
This file contains hidden or 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(): | |
import sys, tty, termios | |
fd = sys.stdin.fileno() | |
old = termios.tcgetattr(fd) | |
try: | |
tty.setraw(fd) | |
return sys.stdin.read(1) | |
finally: | |
termios.tcsetattr(fd, termios.TCSADRAIN, old) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment