summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-05-30 18:54:59 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-05-30 18:54:59 +0100
commitbf1b8101a3060d2d342e2ff2bf7cfa0a58fc1b56 (patch)
treefa6bc042637b71bc9fa3359268a3fb2fc6149e28
parent11c6b4f8c36374e822dd055aa40d80b969a97f9c (diff)
downloadkeyboard-python-bf1b8101a3060d2d342e2ff2bf7cfa0a58fc1b56.tar.bz2
Put all [ codes in the table
this means none are hidden by the regex
-rw-r--r--keyboardpython/key.py59
1 files changed, 30 insertions, 29 deletions
diff --git a/keyboardpython/key.py b/keyboardpython/key.py
index f952a56..09d8007 100644
--- a/keyboardpython/key.py
+++ b/keyboardpython/key.py
@@ -107,22 +107,34 @@ _special_chars = {
Backspace: Key('Backspace'),
}
_escape_brace_codes = {
- 'A': Key('Up'),
- 'B': Key('Down'),
- 'D': Key('Left'),
- 'C': Key('Right'),
- '3~': Key('Del'),
- '2~': Key('Insert'),
- '5~': Key('PageUp'),
- '6~': Key('PageDown'),
- '15~': Key('F5'),
- '17~': Key('F6'),
- '18~': Key('F7'),
- '19~': Key('F8'),
- '20~': Key('F9'),
- '21~': Key('F10'),
- '23~': Key('F11'),
- '24~': Key('F12'),
+ 'A': KeyCombination(Key('Up')),
+ 'B': KeyCombination(Key('Down')),
+ 'D': KeyCombination(Key('Left')),
+ 'C': KeyCombination(Key('Right')),
+ '3~': KeyCombination(Key('Del')),
+ '2~': KeyCombination(Key('Insert')),
+ '5~': KeyCombination(Key('PageUp')),
+ '6~': KeyCombination(Key('PageDown')),
+ '15~': KeyCombination(Key('F5')),
+ '17~': KeyCombination(Key('F6')),
+ '18~': KeyCombination(Key('F7')),
+ '19~': KeyCombination(Key('F8')),
+ '20~': KeyCombination(Key('F9')),
+ '21~': KeyCombination(Key('F10')),
+ '23~': KeyCombination(Key('F11')),
+ '24~': KeyCombination(Key('F12')),
+ '3;3~': KeyCombination(Key('Del'),ALT),
+ '2;3~': KeyCombination(Key('Insert'),ALT),
+ '5;3~': KeyCombination(Key('PageUp'),ALT),
+ '6;3~': KeyCombination(Key('PageDown'),ALT),
+ '15;3~': KeyCombination(Key('F5'),ALT),
+ '17;3~': KeyCombination(Key('F6'),ALT),
+ '18;3~': KeyCombination(Key('F7'),ALT),
+ '19;3~': KeyCombination(Key('F8'),ALT),
+ '20;3~': KeyCombination(Key('F9'),ALT),
+ '21;3~': KeyCombination(Key('F10'),ALT),
+ '23;3~': KeyCombination(Key('F11'),ALT),
+ '24;3~': KeyCombination(Key('F12'),ALT),
}
_escape_O_codes = {
'F': KeyCombination(Key('End')),
@@ -180,22 +192,11 @@ def parse_code(code):
for c in _escape_brace_codes.keys():
match = re.search('^%s' % c,code_str)
if match:
- key = _escape_brace_codes[match.string]
- to_return.add_key(key)
+ key_comb = _escape_brace_codes[match.string]
+ to_return.add_keyCombination(key_comb)
len_match = len(match.string)
_code = _code[len_match:]
break
- #TODO HACK - remove
- else:
- alt_code_str = re.sub(';3~','~',code_str)
- match = re.search('^%s' % c,alt_code_str)
- if match:
- key = _escape_brace_codes[match.string]
- to_return.add_key(key)
- to_return.add_key(ALT)
- len_match = len(match.string)
- _code = _code[len_match+2:]
- break
elif _code[0] == 'O':
import re
_code.pop(0)