Invokes a callback every time a specific hotkey sequence is detected. The callback is executed asynchronously in a separate thread.
Hotkeys must follow the format ctrl+shift+a, s (e.g., hold ctrl, shift, and 'a', release, then press 's'). To use literal characters like commas or pluses, use their names (e.g., 'comma', 'plus').
Options:
args (list): Optional arguments passed to the callback.suppress (bool): If true, successful triggers block keys from being sent to other programs. Defaults to False.timeout (float): Seconds allowed between key presses. Defaults to 1.trigger_on_release (bool): If true, callback triggers on key release instead of press. Defaults to False.
To remove a hotkey, use remove_hotkey(hotkey) or remove_hotkey(handler) using the returned handler.
# Different but equivalent ways to listen for a spacebar key press.
add_hotkey(' ', print, args=['space was pressed'])
add_hotkey('space', print, args=['space was pressed'])
add_hotkey('Space', print, args=['space was pressed'])
# Using scan code 57 for spacebar
add_hotkey(57, print, args=['space was pressed'])
add_hotkey('ctrl+q', quit)
add_hotkey('ctrl+alt+enter, space', some_callback)