summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-06-02 18:31:43 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-06-02 18:31:43 +0100
commit3927b1347e66c721cbefbf559eeac7950dbda5fa (patch)
tree4d52d1694a246553c862664b1eac68a1795ae4e1
parenta6310dce41fd777629ddbea5e9977d6f505459ea (diff)
downloadkeyboard-python-3927b1347e66c721cbefbf559eeac7950dbda5fa.tar.bz2
Fix VMIN and VTIME not getting set
-rw-r--r--keyboardpython/__init__.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/keyboardpython/__init__.py b/keyboardpython/__init__.py
index f97283a..2996c7a 100644
--- a/keyboardpython/__init__.py
+++ b/keyboardpython/__init__.py
@@ -32,12 +32,13 @@ def set_to_read_key(fd='default'):
if fd == 'default': fd = sys.stdin.fileno()
global before_t
before_t = termios.tcgetattr(fd)
- t = termios.tcgetattr(fd)
noecho()
cbreak()
+ t = termios.tcgetattr(fd)
cc = t[-1]
cc[termios.VMIN] = VMIN
cc[termios.VTIME] = VTIME
+ termios.tcsetattr(fd, termios.TCSANOW, t)
def reset_tty(fd='default'):
''' set tty to how it was before set_to_read_key '''
@@ -45,7 +46,7 @@ def reset_tty(fd='default'):
if fd == 'default': fd = sys.stdin.fileno()
termios.tcsetattr(fd, termios.TCSANOW, before_t)
-def getkey(fd='default',timeout=40,buffersize=6):
+def getkey(fd='default',timeout=32,buffersize=6):
''' Read keypress and return Key object.
- fd='default' will try and get this stdin.