From 7f470927084772f6f58b47e92b28e8cc73e0c186 Mon Sep 17 00:00:00 2001 From: Dobromir Ivanov Date: Sun, 8 Nov 2020 18:50:10 +0200 Subject: [PATCH] Bugfix: Calling getkey(blocking=False) results in missed keyboard inputs Inputs are missed, because when setting `tty.setcbreak` the default value of the `when` argument is used which means that the option will have effect after transmitting all queued output and discarding all queued input which may not happen immediately so some inputs will be lost. References: - https://docs.python.org/3/library/tty.html - https://docs.python.org/3/library/termios.html#termios.tcsetattr --- getkey/platforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getkey/platforms.py b/getkey/platforms.py index 3bb4345..9723c25 100644 --- a/getkey/platforms.py +++ b/getkey/platforms.py @@ -113,7 +113,7 @@ def fileno(self): def context(self): fd = self.fileno() old_settings = self.termios.tcgetattr(fd) - self.tty.setcbreak(fd) + self.tty.setcbreak(fd, self.termios.TCSANOW) try: yield finally: