@@ -3,6 +3,7 @@ This type stub file was generated by pyright.
3
3
"""
4
4
from __future__ import print_function as _print_function
5
5
import typing
6
+ import collections .abc
6
7
7
8
import re as _re
8
9
import itertools as _itertools
@@ -13,6 +14,7 @@ from threading import Lock as _Lock, Thread as _Thread
13
14
from ._keyboard_event import KEY_DOWN , KEY_UP , KeyboardEvent
14
15
from ._generic import GenericListener as _GenericListener
15
16
from ._canonical_names import all_modifiers , normalize_name , sided_modifiers
17
+ __all__ = ["all_modifiers" , "normalize_name" , "sided_modifiers" , "KEY_DOWN" , "KEY_UP" , "KeyboardEvent" ]
16
18
17
19
try :
18
20
# Python2
@@ -103,12 +105,12 @@ key events. In this case `keyboard` will be unable to report events.
103
105
- This program makes no attempt to hide itself, so don't use it for keyloggers or online gaming bots. Be responsible.
104
106
"""
105
107
106
- Callback = typing .Callable [[KeyboardEvent ], None ]
108
+ Callback = collections . abc .Callable [[KeyboardEvent ], None ]
107
109
108
110
version : str
109
- _is_str = typing .Callable [[typing .Any ], bool ]
110
- _is_number = typing .Callable [[typing .Any ], bool ]
111
- _is_list : typing .Callable [[typing .Any ], bool ]
111
+ _is_str = collections . abc .Callable [[typing .Any ], bool ]
112
+ _is_number = collections . abc .Callable [[typing .Any ], bool ]
113
+ _is_list : collections . abc .Callable [[typing .Any ], bool ]
112
114
113
115
114
116
class _State :
@@ -120,10 +122,6 @@ class _Event(_UninterruptibleEvent):
120
122
...
121
123
122
124
123
- if _platform .system () == 'Windows' :
124
- ...
125
- else :
126
- ...
127
125
_modifier_scan_codes : set
128
126
129
127
@@ -197,14 +195,16 @@ class _KeyboardListener(_GenericListener):
197
195
_listener : _KeyboardListener
198
196
199
197
200
- def key_to_scan_codes (key : typing .Union [int , str , typing .List [typing .Union [int , str ]]], error_if_missing : bool = ...) -> typing .List [int ]:
198
+ def key_to_scan_codes (key : typing .Union [int , str , typing .List [typing .Union [int , str ]]],
199
+ error_if_missing : bool = ...) -> typing .List [int ]:
201
200
"""
202
201
Returns a list of scan codes associated with this key (name or scan code).
203
202
"""
204
203
...
205
204
206
205
207
- def parse_hotkey (hotkey ) -> tuple [tuple [tuple [Unknown ] | Unknown | tuple [()] | tuple [Unknown , ...]]] | tuple [tuple [tuple [Unknown ] | Unknown | tuple [()] | tuple [Unknown , ...], ...]] | tuple [Unknown , ...]:
206
+ def parse_hotkey (hotkey ) -> tuple [tuple [tuple [Unknown ] | Unknown | tuple [()] | tuple [Unknown , ...]]
207
+ ] | tuple [tuple [tuple [Unknown ] | Unknown | tuple [()] | tuple [Unknown , ...], ...]] | tuple [Unknown , ...]:
208
208
"""
209
209
Parses a user-provided hotkey into nested tuples representing the
210
210
parsed structure, with the bottom values being lists of scan codes.
@@ -274,10 +274,10 @@ def call_later(fn, args=..., delay=...) -> None:
274
274
...
275
275
276
276
277
- _hooks : dict [typing .Callable , Unknown ]
277
+ _hooks : dict [collections . abc .Callable , Unknown ]
278
278
279
279
280
- def hook (callback : Callback , suppress = ..., on_remove = ...) -> typing .Callable [[], None ]:
280
+ def hook (callback : Callback , suppress = ..., on_remove = ...) -> collections . abc .Callable [[], None ]:
281
281
"""
282
282
Installs a global listener on all available keyboards, invoking `callback`
283
283
each time a key is pressed or released.
@@ -296,21 +296,22 @@ def hook(callback: Callback, suppress=..., on_remove=...) -> typing.Callable[[],
296
296
...
297
297
298
298
299
- def on_press (callback : Callback , suppress = ...) -> typing .Callable [[], None ]:
299
+ def on_press (callback : Callback , suppress = ...) -> collections . abc .Callable [[], None ]:
300
300
"""
301
301
Invokes `callback` for every KEY_DOWN event. For details see `hook`.
302
302
"""
303
303
...
304
304
305
305
306
- def on_release (callback : Callback , suppress = ...) -> typing .Callable [[], None ]:
306
+ def on_release (callback : Callback , suppress = ...) -> collections . abc .Callable [[], None ]:
307
307
"""
308
308
Invokes `callback` for every KEY_UP event. For details see `hook`.
309
309
"""
310
310
...
311
311
312
312
313
- def hook_key (key : typing .Union [int , str , typing .List [typing .Union [int , str ]]], callback : Callback , suppress : bool = ...) -> typing .Callable [[], None ]:
313
+ def hook_key (key : typing .Union [int , str , typing .List [typing .Union [int , str ]]],
314
+ callback : Callback , suppress : bool = ...) -> collections .abc .Callable [[], None ]:
314
315
"""
315
316
Hooks key up and key down events for a single key. Returns the event handler
316
317
created. To remove a hooked key use `unhook_key(key)` or
@@ -322,21 +323,21 @@ def hook_key(key: typing.Union[int, str, typing.List[typing.Union[int, str]]], c
322
323
...
323
324
324
325
325
- def on_press_key (key , callback : Callback , suppress = ...) -> typing .Callable [[], None ]:
326
+ def on_press_key (key , callback : Callback , suppress = ...) -> collections . abc .Callable [[], None ]:
326
327
"""
327
328
Invokes `callback` for KEY_DOWN event related to the given key. For details see `hook`.
328
329
"""
329
330
...
330
331
331
332
332
- def on_release_key (key , callback : Callback , suppress = ...) -> typing .Callable [[], None ]:
333
+ def on_release_key (key , callback : Callback , suppress = ...) -> collections . abc .Callable [[], None ]:
333
334
"""
334
335
Invokes `callback` for KEY_UP event related to the given key. For details see `hook`.
335
336
"""
336
337
...
337
338
338
339
339
- def unhook (remove : typing .Callable [[], None ]) -> None :
340
+ def unhook (remove : collections . abc .Callable [[], None ]) -> None :
340
341
"""
341
342
Removes a previously added hook, either by callback or by the return value
342
343
of `hook`.
@@ -355,7 +356,7 @@ def unhook_all() -> None:
355
356
...
356
357
357
358
358
- def block_key (key ) -> typing .Callable [[], None ]:
359
+ def block_key (key ) -> collections . abc .Callable [[], None ]:
359
360
"""
360
361
Suppresses all key events of the given key, regardless of modifiers.
361
362
"""
@@ -365,7 +366,7 @@ def block_key(key) -> typing.Callable[[], None]:
365
366
unblock_key = unhook_key
366
367
367
368
368
- def remap_key (src , dst ) -> typing .Callable [[], None ]:
369
+ def remap_key (src , dst ) -> collections . abc .Callable [[], None ]:
369
370
"""
370
371
Whenever the key `src` is pressed or released, regardless of modifiers,
371
372
press or release the hotkey `dst` instead.
@@ -388,7 +389,8 @@ def parse_hotkey_combinations(hotkey) -> tuple[tuple[tuple[Unknown, ...], ...],
388
389
_hotkeys : dict
389
390
390
391
391
- def add_hotkey (hotkey , callback : Callback , args = ..., suppress = ..., timeout = ..., trigger_on_release = ...) -> typing .Callable [[], None ]:
392
+ def add_hotkey (hotkey , callback : collections .abc .Callable , args = ..., suppress = ..., timeout = ...,
393
+ trigger_on_release = ...) -> collections .abc .Callable [[], None ]:
392
394
"""
393
395
Invokes a callback every time a hotkey is pressed. The hotkey must
394
396
be in the format `ctrl+shift+a, s`. This would trigger when the user holds
@@ -453,7 +455,7 @@ def unhook_all_hotkeys() -> None:
453
455
unregister_all_hotkeys = remove_all_hotkeys = clear_all_hotkeys = unhook_all_hotkeys
454
456
455
457
456
- def remap_hotkey (src , dst , suppress = ..., trigger_on_release = ...) -> typing .Callable [[], None ]:
458
+ def remap_hotkey (src , dst , suppress = ..., trigger_on_release = ...) -> collections . abc .Callable [[], None ]:
457
459
"""
458
460
Whenever the hotkey `src` is pressed, suppress it and send
459
461
`dst` instead.
@@ -589,10 +591,11 @@ def get_typed_strings(events, allow_backspace=...):
589
591
...
590
592
591
593
592
- _recording : typing .Optional [tuple [Unknown | _queue .Queue [Unknown ], typing .Callable [[], None ]]]
594
+ _recording : typing .Optional [tuple [Unknown | _queue .Queue [Unknown ], collections . abc .Callable [[], None ]]]
593
595
594
596
595
- def start_recording (recorded_events_queue = ...) -> tuple [Unknown | _queue .Queue [Unknown ], typing .Callable [[], None ]]:
597
+ def start_recording (recorded_events_queue = ...) -> tuple [Unknown
598
+ | _queue .Queue [Unknown ], collections .abc .Callable [[], None ]]:
596
599
"""
597
600
Starts recording all keyboard events into a global variable, or the given
598
601
queue if any. Returns the queue of events and the hooked function.
@@ -639,7 +642,13 @@ replay = play
639
642
_word_listeners : dict
640
643
641
644
642
- def add_word_listener (word , callback : Callback , triggers = ..., match_suffix = ..., timeout = ...) -> typing .Callable [[], None ]:
645
+ def add_word_listener (
646
+ word ,
647
+ callback : Callback ,
648
+ triggers = ...,
649
+ match_suffix = ...,
650
+ timeout = ...) -> collections .abc .Callable [[],
651
+ None ]:
643
652
"""
644
653
Invokes a callback every time a sequence of characters is typed (e.g. 'pet')
645
654
and followed by a trigger key (e.g. space). Modifiers (e.g. alt, ctrl,
@@ -676,7 +685,8 @@ def remove_word_listener(word_or_handler) -> None:
676
685
...
677
686
678
687
679
- def add_abbreviation (source_text , replacement_text , match_suffix = ..., timeout = ...) -> typing .Callable [[], None ]:
688
+ def add_abbreviation (source_text , replacement_text , match_suffix = ...,
689
+ timeout = ...) -> collections .abc .Callable [[], None ]:
680
690
"""
681
691
Registers a hotkey that replaces one typed text with another. For example
682
692
0 commit comments