def get_hotkey_name(names=None):
if names is None:<EOL><INDENT>_listener.start_if_necessary()<EOL>with _pressed_events_lock:<EOL><INDENT>names = [e.name for e in _pressed_events.values()]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>names = [normalize_name(name) for name in names]<EOL><DEDENT>clean_names = set(e.replace('<STR_LIT>', '<STR_LIT>').replace('<STR_LIT>', '<STR_LIT>').replace('<STR_LIT:+>', '<STR_LIT>') for e in names)<EOL>modifiers = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>sorting_key = lambda k: (modifiers.index(k) if k in modifiers else <NUM_LIT:5>, str(k))<EOL>return '<STR_LIT:+>'.join(sorted(clean_names, key=sorting_key))<EOL>
Returns a string representation of hotkey from the given key names, or
the currently pressed keys if not given.  This function:

- normalizes names;
- removes "left" and "right" prefixes;
- replaces the "+" key name with "plus" to avoid ambiguity;
- puts modifier keys first, in a standardized order;
- sort remaining keys;
- finally, joins everything with "+".

Example:

    get_hotkey_name(['+', 'left ctrl', 'shift'])
    # "ctrl+shift+plus"