Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ def add_hotkey(hotkey, callback, args=(), suppress=False, timeout=1, trigger_on_
`remove_hotkey(hotkey)` or `remove_hotkey(handler)`.
before the hotkey state is reset.

To loop on waiting for hotkeys, call `wait()` after all hotkeys are
registered.

Note: hotkeys are activated when the last key is *pressed*, not released.
Note: the callback is executed in a separate thread, asynchronously. For an
example of how to use a callback synchronously, see `wait`.
Expand All @@ -632,6 +635,8 @@ def add_hotkey(hotkey, callback, args=(), suppress=False, timeout=1, trigger_on_

add_hotkey('ctrl+q', quit)
add_hotkey('ctrl+alt+enter, space', some_callback)

wait()
"""
if args:
callback = lambda callback=callback: callback(*args)
Expand Down Expand Up @@ -1154,4 +1159,4 @@ def add_abbreviation(source_text, replacement_text, match_suffix=False, timeout=
# Aliases.
register_word_listener = add_word_listener
register_abbreviation = add_abbreviation
remove_abbreviation = remove_word_listener
remove_abbreviation = remove_word_listener