@@ -126,6 +126,7 @@ key events. In this case `keyboard` will be unable to report events.
126
126
- [ keyboard.** add\_ word\_ listener** ] ( #keyboard.add_word_listener ) * (aliases: ` register_word_listener ` )*
127
127
- [ keyboard.** remove\_ word\_ listener** ] ( #keyboard.remove_word_listener ) * (aliases: ` remove_abbreviation ` )*
128
128
- [ keyboard.** add\_ abbreviation** ] ( #keyboard.add_abbreviation ) * (aliases: ` register_abbreviation ` )*
129
+ - [ keyboard.** normalize\_ name** ] ( #keyboard.normalize_name )
129
130
130
131
131
132
<a name =" keyboard.KEY_DOWN " />
@@ -224,7 +225,7 @@ Returns True if `key` is a scan code or name of a modifier key.
224
225
225
226
## keyboard.** key\_ to\_ scan\_ codes** (key, error\_ if\_ missing=True)
226
227
227
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L300 )
228
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L296 )
228
229
229
230
230
231
Returns a list of scan codes associated with this key (name or scan code).
@@ -235,7 +236,7 @@ Returns a list of scan codes associated with this key (name or scan code).
235
236
236
237
## keyboard.** parse\_ hotkey** (hotkey)
237
238
238
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L330 )
239
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L326 )
239
240
240
241
241
242
Parses a user-provided hotkey into nested tuples representing the
@@ -260,7 +261,7 @@ parse_hotkey("alt+shift+a, alt+b, c")
260
261
261
262
## keyboard.** send** (hotkey, do\_ press=True, do\_ release=True)
262
263
263
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L363 )
264
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L359 )
264
265
265
266
266
267
Sends OS events that perform the given * hotkey* hotkey.
@@ -286,7 +287,7 @@ Note: keys are released in the opposite order they were pressed.
286
287
287
288
## keyboard.** press** (hotkey)
288
289
289
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L396 )
290
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L392 )
290
291
291
292
Presses and holds down a hotkey (see [ ` send ` ] ( #keyboard.send ) ).
292
293
@@ -295,7 +296,7 @@ Presses and holds down a hotkey (see [`send`](#keyboard.send)).
295
296
296
297
## keyboard.** release** (hotkey)
297
298
298
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L400 )
299
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L396 )
299
300
300
301
Releases a hotkey (see [ ` send ` ] ( #keyboard.send ) ).
301
302
@@ -304,7 +305,7 @@ Releases a hotkey (see [`send`](#keyboard.send)).
304
305
305
306
## keyboard.** is\_ pressed** (hotkey)
306
307
307
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L404 )
308
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L400 )
308
309
309
310
310
311
Returns True if the key is pressed.
@@ -322,7 +323,7 @@ is_pressed('ctrl+space') #-> True
322
323
323
324
## keyboard.** call\_ later** (fn, args=(), delay=0.001)
324
325
325
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L431 )
326
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L427 )
326
327
327
328
328
329
Calls the provided function in a new thread after waiting some time.
@@ -335,7 +336,7 @@ the current execution flow.
335
336
336
337
## keyboard.** hook** (callback, suppress=False, on\_ remove=< ; lambda> ; )
337
338
338
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L441 )
339
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L437 )
339
340
340
341
341
342
Installs a global listener on all available keyboards, invoking ` callback `
@@ -358,7 +359,7 @@ Returns the given callback for easier development.
358
359
359
360
## keyboard.** on\_ press** (callback, suppress=False)
360
361
361
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L472 )
362
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L468 )
362
363
363
364
364
365
Invokes ` callback ` for every KEY_DOWN event. For details see [ ` hook ` ] ( #keyboard.hook ) .
@@ -369,7 +370,7 @@ Invokes `callback` for every KEY_DOWN event. For details see [`hook`](#keyboard.
369
370
370
371
## keyboard.** on\_ release** (callback, suppress=False)
371
372
372
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L478 )
373
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L474 )
373
374
374
375
375
376
Invokes ` callback ` for every KEY_UP event. For details see [ ` hook ` ] ( #keyboard.hook ) .
@@ -380,7 +381,7 @@ Invokes `callback` for every KEY_UP event. For details see [`hook`](#keyboard.ho
380
381
381
382
## keyboard.** hook\_ key** (key, callback, suppress=False)
382
383
383
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L484 )
384
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L480 )
384
385
385
386
386
387
Hooks key up and key down events for a single key. Returns the event handler
@@ -396,7 +397,7 @@ affects it aswell.
396
397
397
398
## keyboard.** on\_ press\_ key** (key, callback, suppress=False)
398
399
399
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L508 )
400
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L504 )
400
401
401
402
402
403
Invokes ` callback ` for KEY_DOWN event related to the given key. For details see [ ` hook ` ] ( #keyboard.hook ) .
@@ -407,7 +408,7 @@ Invokes `callback` for KEY_DOWN event related to the given key. For details see
407
408
408
409
## keyboard.** on\_ release\_ key** (key, callback, suppress=False)
409
410
410
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L514 )
411
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L510 )
411
412
412
413
413
414
Invokes ` callback ` for KEY_UP event related to the given key. For details see [ ` hook ` ] ( #keyboard.hook ) .
@@ -418,7 +419,7 @@ Invokes `callback` for KEY_UP event related to the given key. For details see [`
418
419
419
420
## keyboard.** unhook** (remove)
420
421
421
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L520 )
422
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L516 )
422
423
423
424
424
425
Removes a previously added hook, either by callback or by the return value
@@ -430,7 +431,7 @@ of [`hook`](#keyboard.hook).
430
431
431
432
## keyboard.** unhook\_ all** ()
432
433
433
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L528 )
434
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L524 )
434
435
435
436
436
437
Removes all keyboard hooks in use, including hotkeys, abbreviations, word
@@ -442,7 +443,7 @@ listeners, [`record`](#keyboard.record)ers and [`wait`](#keyboard.wait)s.
442
443
443
444
## keyboard.** block\_ key** (key)
444
445
445
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L539 )
446
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L536 )
446
447
447
448
448
449
Suppresses all key events of the given key, regardless of modifiers.
@@ -453,7 +454,7 @@ Suppresses all key events of the given key, regardless of modifiers.
453
454
454
455
## keyboard.** remap\_ key** (src, dst)
455
456
456
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L546 )
457
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L543 )
457
458
458
459
459
460
Whenever the key ` src ` is pressed or released, regardless of modifiers,
@@ -465,7 +466,7 @@ press or release the hotkey `dst` instead.
465
466
466
467
## keyboard.** parse\_ hotkey\_ combinations** (hotkey)
467
468
468
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L560 )
469
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L557 )
469
470
470
471
471
472
Parses a user-provided hotkey. Differently from [ ` parse_hotkey ` ] ( #keyboard.parse_hotkey ) ,
@@ -478,7 +479,7 @@ each step is a list of all possible combinations of those scan codes.
478
479
479
480
## keyboard.** add\_ hotkey** (hotkey, callback, args=(), suppress=False, timeout=1, trigger\_ on\_ release=False)
480
481
481
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L600 )
482
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L597 )
482
483
483
484
484
485
Invokes a callback every time a hotkey is pressed. The hotkey must
@@ -525,7 +526,7 @@ add_hotkey('ctrl+alt+enter, space', some_callback)
525
526
526
527
## keyboard.** remove\_ hotkey** (hotkey\_ or\_ callback)
527
528
528
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L746 )
529
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L743 )
529
530
530
531
531
532
Removes a previously hooked hotkey. Must be called wtih the value returned
@@ -537,7 +538,7 @@ by [`add_hotkey`](#keyboard.add_hotkey).
537
538
538
539
## keyboard.** unhook\_ all\_ hotkeys** ()
539
540
540
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L754 )
541
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L751 )
541
542
542
543
543
544
Removes all keyboard hotkeys in use, including abbreviations, word listeners,
@@ -549,7 +550,7 @@ Removes all keyboard hotkeys in use, including abbreviations, word listeners,
549
550
550
551
## keyboard.** remap\_ hotkey** (src, dst, suppress=True, trigger\_ on\_ release=False)
551
552
552
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L765 )
553
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L762 )
553
554
554
555
555
556
Whenever the hotkey ` src ` is pressed, suppress it and send
@@ -568,7 +569,7 @@ remap('alt+w', 'ctrl+up')
568
569
569
570
## keyboard.** stash\_ state** ()
570
571
571
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L785 )
572
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L782 )
572
573
573
574
574
575
Builds a list of all currently pressed scan codes, releases them and returns
@@ -580,7 +581,7 @@ the list. Pairs well with [`restore_state`](#keyboard.restore_state) and [`resto
580
581
581
582
## keyboard.** restore\_ state** (scan\_ codes)
582
583
583
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L797 )
584
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L794 )
584
585
585
586
586
587
Given a list of scan_codes ensures these keys, and only these keys, are
@@ -592,7 +593,7 @@ pressed. Pairs well with [`stash_state`](#keyboard.stash_state), alternative to
592
593
593
594
## keyboard.** restore\_ modifiers** (scan\_ codes)
594
595
595
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L814 )
596
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L811 )
596
597
597
598
598
599
Like [ ` restore_state ` ] ( #keyboard.restore_state ) , but only restores modifier keys.
@@ -603,7 +604,7 @@ Like [`restore_state`](#keyboard.restore_state), but only restores modifier keys
603
604
604
605
## keyboard.** write** (text, delay=0, restore\_ state\_ after=True, exact=None)
605
606
606
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L820 )
607
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L817 )
607
608
608
609
609
610
Sends artificial keyboard events to the OS, simulating the typing of a given
@@ -628,7 +629,7 @@ value.
628
629
629
630
## keyboard.** wait** (hotkey=None, suppress=False, trigger\_ on\_ release=False)
630
631
631
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L875 )
632
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L872 )
632
633
633
634
634
635
Blocks the program execution until the given hotkey is pressed or,
@@ -640,7 +641,7 @@ if given no parameters, blocks forever.
640
641
641
642
## keyboard.** get\_ hotkey\_ name** (names=None)
642
643
643
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L889 )
644
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L886 )
644
645
645
646
646
647
Returns a string representation of hotkey from the given key names, or
@@ -667,7 +668,7 @@ get_hotkey_name(['+', 'left ctrl', 'shift'])
667
668
668
669
## keyboard.** read\_ event** (suppress=False)
669
670
670
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L920 )
671
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L917 )
671
672
672
673
673
674
Blocks until a keyboard event happens, then returns that event.
@@ -678,7 +679,7 @@ Blocks until a keyboard event happens, then returns that event.
678
679
679
680
## keyboard.** read\_ key** (suppress=False)
680
681
681
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L931 )
682
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L928 )
682
683
683
684
684
685
Blocks until a keyboard event happens, then returns that event's name or,
@@ -690,7 +691,7 @@ if missing, its scan code.
690
691
691
692
## keyboard.** read\_ hotkey** (suppress=True)
692
693
693
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L939 )
694
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L936 )
694
695
695
696
696
697
Similar to [ ` read_key() ` ] ( #keyboard.read_key ) , but blocks until the user presses and releases a
@@ -711,7 +712,7 @@ read_hotkey()
711
712
712
713
## keyboard.** get\_ typed\_ strings** (events, allow\_ backspace=True)
713
714
714
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L961 )
715
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L958 )
715
716
716
717
717
718
Given a sequence of events, tries to deduce what strings were typed.
@@ -738,7 +739,7 @@ get_type_strings(record()) #-> ['This is what', 'I recorded', '']
738
739
739
740
## keyboard.** start\_ recording** (recorded\_ events\_ queue=None)
740
741
741
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1006 )
742
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1005 )
742
743
743
744
744
745
Starts recording all keyboard events into a global variable, or the given
@@ -752,7 +753,7 @@ Use [`stop_recording()`](#keyboard.stop_recording) or [`unhook(hooked_function)`
752
753
753
754
## keyboard.** stop\_ recording** ()
754
755
755
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1018 )
756
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1017 )
756
757
757
758
758
759
Stops the global recording of events and returns a list of the events
@@ -764,7 +765,7 @@ captured.
764
765
765
766
## keyboard.** record** (until=' ; escape' ; , suppress=False, trigger\_ on\_ release=False)
766
767
767
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1030 )
768
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1029 )
768
769
769
770
770
771
Records all keyboard events from all keyboards until the user presses the
@@ -781,7 +782,7 @@ Note: for more details on the keyboard hook and events see [`hook`](#keyboard.ho
781
782
782
783
## keyboard.** play** (events, speed\_ factor=1.0)
783
784
784
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1044 )
785
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1043 )
785
786
786
787
787
788
Plays a sequence of recorded events, maintaining the relative time
@@ -797,7 +798,7 @@ the end of the function.
797
798
798
799
## keyboard.** add\_ word\_ listener** (word, callback, triggers=[ ' ; space' ; ] , match\_ suffix=False, timeout=2)
799
800
800
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1068 )
801
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1067 )
801
802
802
803
803
804
Invokes a callback every time a sequence of characters is typed (e.g. 'pet')
@@ -821,15 +822,15 @@ Returns the event handler created. To remove a word listener use
821
822
[ ` remove_word_listener(word) ` ] ( #keyboard.remove_word_listener ) or [ ` remove_word_listener(handler) ` ] ( #keyboard.remove_word_listener ) .
822
823
823
824
Note: all actions are performed on key down. Key up events are ignored.
824
- Note: word matches are ** case sensitive** .
825
+ Note: word mathes are ** case sensitive** .
825
826
826
827
827
828
828
829
<a name =" keyboard.remove_word_listener " />
829
830
830
831
## keyboard.** remove\_ word\_ listener** (word\_ or\_ handler)
831
832
832
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1124 )
833
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1123 )
833
834
834
835
835
836
Removes a previously registered word listener. Accepts either the word used
@@ -842,7 +843,7 @@ during registration (exact string) or the event handler returned by the
842
843
843
844
## keyboard.** add\_ abbreviation** (source\_ text, replacement\_ text, match\_ suffix=False, timeout=2)
844
845
845
- [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1132 )
846
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1131 )
846
847
847
848
848
849
Registers a hotkey that replaces one typed text with another. For example
@@ -865,3 +866,15 @@ For more details see [`add_word_listener`](#keyboard.add_word_listener).
865
866
866
867
867
868
869
+ <a name =" keyboard.normalize_name " />
870
+
871
+ ## keyboard.** normalize\_ name** (name)
872
+
873
+ [ \[ source\] ] ( https://github.com/boppreh/keyboard/blob/master/keyboard/_canonical_names.py#L1233 )
874
+
875
+
876
+ Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to
877
+ the canonical representation (e.g. "left ctrl") if one is known.
878
+
879
+
880
+
0 commit comments