Translate from keycap symbol to the Tkinter keysym.
(key, modifiers)
| 22 | |
| 23 | |
| 24 | def translate_key(key, modifiers): |
| 25 | "Translate from keycap symbol to the Tkinter keysym." |
| 26 | mapping = {'Space':'space', |
| 27 | '~':'asciitilde', '!':'exclam', '@':'at', '#':'numbersign', |
| 28 | '%':'percent', '^':'asciicircum', '&':'ampersand', |
| 29 | '*':'asterisk', '(':'parenleft', ')':'parenright', |
| 30 | '_':'underscore', '-':'minus', '+':'plus', '=':'equal', |
| 31 | '{':'braceleft', '}':'braceright', |
| 32 | '[':'bracketleft', ']':'bracketright', '|':'bar', |
| 33 | ';':'semicolon', ':':'colon', ',':'comma', '.':'period', |
| 34 | '<':'less', '>':'greater', '/':'slash', '?':'question', |
| 35 | 'Page Up':'Prior', 'Page Down':'Next', |
| 36 | 'Left Arrow':'Left', 'Right Arrow':'Right', |
| 37 | 'Up Arrow':'Up', 'Down Arrow': 'Down', 'Tab':'Tab'} |
| 38 | key = mapping.get(key, key) |
| 39 | if 'Shift' in modifiers and key in string.ascii_lowercase: |
| 40 | key = key.upper() |
| 41 | return f'Key-{key}' |
| 42 | |
| 43 | |
| 44 | class GetKeysFrame(Frame): |
no test coverage detected
searching dependent graphs…