(key, modifiers)
return f'Key-{key}'
Translate from keycap symbol to the Tkinter keysym.
Translate from keycap symbol to the Tkinter keysym.
Translate from keycap symbol to the Tkinter keysym .
def translate_key(key, modifiers):
    "Translate from keycap symbol to the Tkinter keysym."
    mapping = {'Space':'space',
            '~':'asciitilde', '!':'exclam', '@':'at', '#':'numbersign',
            '%':'percent', '^':'asciicircum', '&':'ampersand',
            '*':'asterisk', '(':'parenleft', ')':'parenright',
            '_':'underscore', '-':'minus', '+':'plus', '=':'equal',
            '{':'braceleft', '}':'braceright',
            '[':'bracketleft', ']':'bracketright', '|':'bar',
            ';':'semicolon', ':':'colon', ',':'comma', '.':'period',
            '<':'less', '>':'greater', '/':'slash', '?':'question',
            'Page Up':'Prior', 'Page Down':'Next',
            'Left Arrow':'Left', 'Right Arrow':'Right',
            'Up Arrow':'Up', 'Down Arrow': 'Down', 'Tab':'Tab'}
    key = mapping.get(key, key)
    if 'Shift' in modifiers and key in string.ascii_lowercase:
        key = key.upper()
    return f'Key-{key}'
def translate_key ( key , modifiers ) : mapping = { 'Space' : 'space' , '~' : 'asciitilde' , '!' : 'exclam' , '@' : 'at' , '#' : 'numbersign' , '%' : 'percent' , '^' : 'asciicircum' , '&' : 'ampersand' , '*' : 'asterisk' , '(' : 'parenleft' , ')' : 'parenright' , '_' : 'underscore' , '-' : 'minus' , '+' : 'plus' , '=' : 'equal' , '{' : 'braceleft' , '}' : 'braceright' , '[' : 'bracketleft' , ']' : 'bracketright' , '|' : 'bar' , ';' : 'semicolon' , ':' : 'colon' , ',' : 'comma' , '.' : 'period' , '<' : 'less' , '>' : 'greater' , '/' : 'slash' , '?' : 'question' , 'Page Up' : 'Prior' , 'Page Down' : 'Next' , 'Left Arrow' : 'Left' , 'Right Arrow' : 'Right' , 'Up Arrow' : 'Up' , 'Down Arrow' : 'Down' , 'Tab' : 'Tab' } key = mapping . get ( key , key ) if 'Shift' in modifiers and key in string . ascii_lowercase : key = key . upper ( ) return f'Key-{key}'