Advertisement
Guest User

Untitled

a guest
May 29th, 2013
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import sys
  2. import tty
  3. import termios
  4.  
  5. ########################################################################
  6.  
  7. class RawInputWrapper(object):
  8.  
  9.   def __init__(self):
  10.     fd = sys.stdin.fileno()
  11.     self.old_settings = termios.tcgetattr(fd)
  12.     tty.setraw(fd)
  13.  
  14.   def cleanup(self):
  15.     fd = sys.stdin.fileno()
  16.     termios.tcsetattr(fd, termios.TCSANOW, self.old_settings)
  17.  
  18. ########################################################################
  19.  
  20. def getch():
  21.   ch = sys.stdin.read(1)
  22.   return ch
  23.  
  24. ########################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement