diff options
author | Wade Brainerd <wadetb@gmail.com> | 2009-09-17 01:15:34 (GMT) |
---|---|---|
committer | Wade Brainerd <wadetb@gmail.com> | 2009-09-17 01:15:34 (GMT) |
commit | a8cb4c620f0558c6ff7729a67cf64c03a9555f94 (patch) | |
tree | 38a3ff579813ac247c558dc7266c2cea4712199d /keyboard.py | |
parent | 8bafd0a23447054fa1a17727ea3e59041ca16bd2 (diff) |
Fix English keymap to include space.
Pick the key which requires the fewest modifiers.
Font tweaks.
Diffstat (limited to 'keyboard.py')
-rw-r--r-- | keyboard.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/keyboard.py b/keyboard.py index c3bfb96..f347790 100644 --- a/keyboard.py +++ b/keyboard.py @@ -370,13 +370,26 @@ class KeyboardData: if letter == '\n' or letter == PARAGRAPH_CODE: return self.find_key_by_label('enter'), 0, 0 - # Look up the key in the letter map. + # Look up the key in the letter map. + # Find the one with the fewest modifier keys. + best_score = 3 + best_result = None + for sig, l in self.letter_map.items(): - if l == letter: + if unicode(l) == unicode(letter): scan, state, group = self.parse_key_sig(sig) - for k in self.keys: - if k['key-scan'] == scan: - return k, state, group + + score = 0 + if state & gtk.gdk.SHIFT_MASK: score += 1 + if state & gtk.gdk.MOD5_MASK: score += 1 + if score < best_score: + best_score = score + best_result = scan, state, group + + if best_result is not None: + for k in self.keys: + if k['key-scan'] == best_result[0]: + return k, best_result[1], best_result[2] return None, None, None |