summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-05-30 22:19:08 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-05-30 22:19:08 +0100
commit552475a7b553820137fa1e57d97ba1b8dfb42261 (patch)
tree62f4124b0ed7780771068470fd6a6d3d3fca5072
parent613cbf3015672acf2174aa6950c47051eaa4eb6e (diff)
downloadkeyboard-python-552475a7b553820137fa1e57d97ba1b8dfb42261.tar.bz2
Fix alt alpha not getting alpha
-rw-r--r--keyboardpython/key.py41
1 files changed, 18 insertions, 23 deletions
diff --git a/keyboardpython/key.py b/keyboardpython/key.py
index fec1075..ed833d8 100644
--- a/keyboardpython/key.py
+++ b/keyboardpython/key.py
@@ -20,18 +20,15 @@ class KeyCombination:
def __init__(self,*keys):
keys = list(keys)
for i,k in enumerate(keys):
- if type(k) is str:
- keys[i] = Key(k)
- else:
- assert isinstance(k,Key)
+ if type(k) is str: keys[i] = Key(k)
+ else: assert isinstance(k,Key)
self.keys = list(set(keys))
def __str__(self):
keys = self.keys
if not self.keys: return ''
to_print = keys.pop(0).name
- while keys:
- to_print += ' %s' % keys.pop(0).name
+ while keys: to_print += ' %s' % keys.pop(0).name
return to_print
def __eq__(self,other):
@@ -52,7 +49,7 @@ class KeyCombination:
assert isinstance(_key,Key)
if self.contains_key(_key): return
self.keys.append(_key)
- self.keys = list(set(keys))
+ self.keys = list(set(self.keys))
def remove_key(self,key):
assert isinstance(_key,Key)
@@ -62,9 +59,8 @@ class KeyCombination:
def add_keyCombination(self,key_comb):
assert isinstance(key_comb,KeyCombination)
- for _key in key_comb.keys:
- self.keys.append(_key)
- self.keys = list(set(keys))
+ for _key in key_comb.keys: self.keys.append(_key)
+ self.keys = list(set(self.keys))
def diff(self,key_comb):
assert isinstance(key_comb,KeyCombination)
@@ -99,15 +95,15 @@ ALT = Key('Alt')
CTRL = Key('Control')
_special_chars = {
- ' ': Key('Space'),
- ESC : Key('Escape'),
- Erase : Key('Erase'),
- NL: Key('Enter'),
- Tab: Key('Tab'),
- CR: Key('CR'),
- vTab: Key('vTab'),
- Alert: Key('Alert'),
- Backspace: Key('Backspace'),
+ ' ': KeyCombination('Space'),
+ ESC : KeyCombination('Escape'),
+ Erase : KeyCombination('Erase'),
+ NL: KeyCombination('Enter'),
+ Tab: KeyCombination('Tab'),
+ CR: KeyCombination('CR'),
+ vTab: KeyCombination('vTab'),
+ Alert: KeyCombination('Alert'),
+ Backspace: KeyCombination('Backspace'),
}
_escape_brace_codes = {
'A': KeyCombination('Up'),
@@ -155,8 +151,7 @@ _escape_O_codes = {
def _is_alt(code):
''' is this the code of a combination modified by Alt? '''
_assert_type(code,str)
- if len(code) == 2 and code[0] == ESC:
- return True
+ if len(code) == 2 and code[0] == ESC: return True
return False
def _is_ctrl_alpha(code):
@@ -202,9 +197,9 @@ def parse_code(code):
elif char == 'O':
_code, key_comb = match_start_in_table(_code,
_escape_O_codes)
- else: key_comb = KeyCombination(ALT)
+ else: key_comb = KeyCombination(char,ALT)
elif char in _special_chars.keys():
- key_comb = KeyCombination(_special_chars[char])
+ key_comb = _special_chars[char]
elif _is_ctrl_alpha(char): key_comb = _get_ctrl_alpha(char)
else: key_comb = KeyCombination(char)
to_return.add_keyCombination(key_comb)