Created
December 28, 2015 00:21
-
-
Save thomasballinger/e80f242a8fc7252376b5 to your computer and use it in GitHub Desktop.
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
import tty | |
import termios | |
import sys | |
class Cbreak(object): | |
def __enter__(self): | |
self.original_stty = termios.tcgetattr(sys.stdin) | |
tty.setcbreak(sys.stdin, termios.TCSANOW) | |
def __exit__(self, *args): | |
termios.tcsetattr(sys.stdin, termios.TCSANOW, self.original_stty) | |
if __name__ == '__main__': | |
with Cbreak(): | |
print 'no enter required' | |
print sys.stdin.read(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment