summaryrefslogtreecommitdiff
path: root/src/keyboard.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-04-09 22:18:36 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-04-09 22:18:36 +0200
commit35b6e146cb6a0b313d6297f0d91654aa21f58c1b (patch)
treefde1876ece761df454766bbf67e4412d7b8b4e36 /src/keyboard.py
parent27a20b349cf1975cd75b3d9bc61155ed58ce01d0 (diff)
downloadpoezio-35b6e146cb6a0b313d6297f0d91654aa21f58c1b.tar.gz
poezio-35b6e146cb6a0b313d6297f0d91654aa21f58c1b.tar.bz2
poezio-35b6e146cb6a0b313d6297f0d91654aa21f58c1b.tar.xz
poezio-35b6e146cb6a0b313d6297f0d91654aa21f58c1b.zip
Basic timed event implementation.
Diffstat (limited to 'src/keyboard.py')
-rw-r--r--src/keyboard.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/keyboard.py b/src/keyboard.py
index 050859a8..cca854fa 100644
--- a/src/keyboard.py
+++ b/src/keyboard.py
@@ -35,7 +35,7 @@ def get_next_byte(s):
try:
c = s.getkey()
except:
- return (None, "KEY_RESIZE")
+ return (None, None)
if len(c) >= 4:
return (None, c)
return (ord(c), c.encode('latin-1')) # returns a number and a bytes object
@@ -47,9 +47,12 @@ def read_char(s):
"""
# We use a timer to know if we are pasting from the
# clipboard or not
- global last_char_time
- last_char_time = time.time()
+ # global last_char_time
+ # last_char_time = time.time()
+ s.timeout(1000)
(first, char) = get_next_byte(s)
+ if first is None:
+ return None
if not isinstance(first, int): # Keyboard special, like KEY_HOME etc
return char
if first == 127 or first == 8:
@@ -57,8 +60,8 @@ def read_char(s):
if first < 127: # ASCII char on one byte
if first <= 26: # transform Ctrl+* keys
char = chr(first + 64)
- if char == 'M' and time.time() - last_char_time < 0.0005:
- char = 'J'
+ # if char == 'M' and time.time() - last_char_time < 0.0005:
+ # char = 'J'
return "^"+char
if first == 27:
second = read_char(s)