Skip to content

Commit

Permalink
Merge pull request #534 from benoit-pierre/osx_key_combo
Browse files Browse the repository at this point in the history
Improve OSX `send_key_combination`
  • Loading branch information
morinted committed Jun 1, 2016
2 parents eb8290d + 91affca commit 5e77cc0
Showing 1 changed file with 1 addition and 43 deletions.
44 changes: 1 addition & 43 deletions plover/oslayer/osxkeyboardcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import collections

from plover.oslayer import mac_keycode
from plover.key_combo import add_modifiers_aliases, parse_key_combo
from plover.key_combo import add_modifiers_aliases, parse_key_combo, KEYNAME_TO_CHAR
import plover.log


Expand Down Expand Up @@ -96,22 +96,6 @@
KEYNAME_TO_KEYCODE[name.lower()] = code + NX_KEY_OFFSET
add_modifiers_aliases(KEYNAME_TO_KEYCODE)

KEYNAME_TO_CHAR = {
'ampersand': '&', 'apostrophe': '\'', 'asciitilde': '~',
'asterisk': '*', 'at': '@', 'backslash': '\'',
'braceleft': '{', 'braceright': '}', 'bracketleft': '[',
'bracketright': ']', 'colon': ':', 'comma': ',', 'division': '÷',
'dollar': '$', 'equal': '=', 'exclam': '!', 'greater': '>',
'hyphen': '-', 'less': '<', 'minus': '-', 'multiply': '×',
'numbersign': '#', 'parenleft': '(', 'parenright': ')',
'percent': '%', 'period': '.', 'plus': '+',
'question': '?', 'quotedbl': '"', 'quoteleft': '‘',
'quoteright': '’', 'semicolon': ';', 'slash': '/', 'space': ' ',
'underscore': '_',
'grave': '`', 'asciicircum': '^',
'bar': '|',
}


def down(seq):
return [(x, True) for x in seq]
Expand All @@ -124,32 +108,6 @@ def up(seq):
def down_up(seq):
return down(seq) + up(seq)

# Maps from literal characters to their key names.
LITERALS = collections.defaultdict(str, {
'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6',
'7': '7', '8': '8', '9': '9',

'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd', 'e': 'e', 'f': 'f', 'g': 'g',
'h': 'h', 'i': 'i', 'j': 'j', 'k': 'k', 'l': 'l', 'm': 'm', 'n': 'n',
'o': 'o', 'p': 'p', 'q': 'q', 'r': 'r', 's': 's', 't': 't', 'u': 'u',
'v': 'v', 'w': 'w', 'x': 'x', 'y': 'y', 'z': 'z',

'A': 'A', 'B': 'B', 'C': 'C', 'D': 'D', 'E': 'E', 'F': 'F', 'G': 'G',
'H': 'H', 'I': 'I', 'J': 'J', 'K': 'K', 'L': 'L', 'M': 'M', 'N': 'N',
'O': 'O', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': 'S', 'T': 'T', 'U': 'U',
'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': 'Z',

'`': 'grave', '~': 'asciitilde', '!': 'exclam', '@': 'at',
'#': 'numbersign', '$': 'dollar', '%': 'percent', '^': 'asciicircum',
'&': 'ampersand', '*': 'asterisk', '(': 'parenleft', ')': 'parenright',
'-': 'minus', '_': 'underscore', '=': 'equal', '+': 'plus',
'[': 'bracketleft', ']': 'bracketright', '{': 'braceleft',
'}': 'braceright', '\\': 'backslash', '|': 'bar', ';': 'semicolon',
':': 'colon', '\'': 'apostrophe', '"': 'quotedbl', ',': 'comma',
'<': 'less', '.': 'period', '>': 'greater', '/': 'slash',
'?': 'question', '\t': 'Tab', ' ': 'space'
})

# Maps from keycodes to corresponding event masks.
MODIFIER_KEYS_TO_MASKS = {
58: kCGEventFlagMaskAlternate,
Expand Down

0 comments on commit 5e77cc0

Please sign in to comment.