Skip to content

Commit c8e30d6

Browse files
committed
Update changes for v0.13.3
1 parent 1a6982e commit c8e30d6

File tree

2 files changed

+62
-40
lines changed

2 files changed

+62
-40
lines changed

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 0.13.3
2+
3+
- [Windows] Fix overflow error on Python 3.7.
4+
- [Mac] Added alt gr -> alt mapping.
5+
- [Mac] Added support for right shift.
6+
- [All] Fixed numlock alias.
7+
- [All] Fixed example code.
8+
9+
110
# 0.13.2
211

312
- [Mac] Fixed "map_name" error (i.e. implement new backend API).

README.md

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ key events. In this case `keyboard` will be unable to report events.
126126
- [keyboard.**add\_word\_listener**](#keyboard.add_word_listener) *(aliases: `register_word_listener`)*
127127
- [keyboard.**remove\_word\_listener**](#keyboard.remove_word_listener) *(aliases: `remove_abbreviation`)*
128128
- [keyboard.**add\_abbreviation**](#keyboard.add_abbreviation) *(aliases: `register_abbreviation`)*
129+
- [keyboard.**normalize\_name**](#keyboard.normalize_name)
129130

130131

131132
<a name="keyboard.KEY_DOWN"/>
@@ -224,7 +225,7 @@ Returns True if `key` is a scan code or name of a modifier key.
224225

225226
## keyboard.**key\_to\_scan\_codes**(key, error\_if\_missing=True)
226227

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)
228229

229230

230231
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).
235236

236237
## keyboard.**parse\_hotkey**(hotkey)
237238

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)
239240

240241

241242
Parses a user-provided hotkey into nested tuples representing the
@@ -260,7 +261,7 @@ parse_hotkey("alt+shift+a, alt+b, c")
260261

261262
## keyboard.**send**(hotkey, do\_press=True, do\_release=True)
262263

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)
264265

265266

266267
Sends OS events that perform the given *hotkey* hotkey.
@@ -286,7 +287,7 @@ Note: keys are released in the opposite order they were pressed.
286287

287288
## keyboard.**press**(hotkey)
288289

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)
290291

291292
Presses and holds down a hotkey (see [`send`](#keyboard.send)).
292293

@@ -295,7 +296,7 @@ Presses and holds down a hotkey (see [`send`](#keyboard.send)).
295296

296297
## keyboard.**release**(hotkey)
297298

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)
299300

300301
Releases a hotkey (see [`send`](#keyboard.send)).
301302

@@ -304,7 +305,7 @@ Releases a hotkey (see [`send`](#keyboard.send)).
304305

305306
## keyboard.**is\_pressed**(hotkey)
306307

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)
308309

309310

310311
Returns True if the key is pressed.
@@ -322,7 +323,7 @@ is_pressed('ctrl+space') #-> True
322323

323324
## keyboard.**call\_later**(fn, args=(), delay=0.001)
324325

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)
326327

327328

328329
Calls the provided function in a new thread after waiting some time.
@@ -335,7 +336,7 @@ the current execution flow.
335336

336337
## keyboard.**hook**(callback, suppress=False, on\_remove=&lt;lambda&gt;)
337338

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)
339340

340341

341342
Installs a global listener on all available keyboards, invoking `callback`
@@ -358,7 +359,7 @@ Returns the given callback for easier development.
358359

359360
## keyboard.**on\_press**(callback, suppress=False)
360361

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)
362363

363364

364365
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.
369370

370371
## keyboard.**on\_release**(callback, suppress=False)
371372

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)
373374

374375

375376
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
380381

381382
## keyboard.**hook\_key**(key, callback, suppress=False)
382383

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)
384385

385386

386387
Hooks key up and key down events for a single key. Returns the event handler
@@ -396,7 +397,7 @@ affects it aswell.
396397

397398
## keyboard.**on\_press\_key**(key, callback, suppress=False)
398399

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)
400401

401402

402403
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
407408

408409
## keyboard.**on\_release\_key**(key, callback, suppress=False)
409410

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)
411412

412413

413414
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 [`
418419

419420
## keyboard.**unhook**(remove)
420421

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)
422423

423424

424425
Removes a previously added hook, either by callback or by the return value
@@ -430,7 +431,7 @@ of [`hook`](#keyboard.hook).
430431

431432
## keyboard.**unhook\_all**()
432433

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)
434435

435436

436437
Removes all keyboard hooks in use, including hotkeys, abbreviations, word
@@ -442,7 +443,7 @@ listeners, [`record`](#keyboard.record)ers and [`wait`](#keyboard.wait)s.
442443

443444
## keyboard.**block\_key**(key)
444445

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)
446447

447448

448449
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.
453454

454455
## keyboard.**remap\_key**(src, dst)
455456

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)
457458

458459

459460
Whenever the key `src` is pressed or released, regardless of modifiers,
@@ -465,7 +466,7 @@ press or release the hotkey `dst` instead.
465466

466467
## keyboard.**parse\_hotkey\_combinations**(hotkey)
467468

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)
469470

470471

471472
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.
478479

479480
## keyboard.**add\_hotkey**(hotkey, callback, args=(), suppress=False, timeout=1, trigger\_on\_release=False)
480481

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)
482483

483484

484485
Invokes a callback every time a hotkey is pressed. The hotkey must
@@ -525,7 +526,7 @@ add_hotkey('ctrl+alt+enter, space', some_callback)
525526

526527
## keyboard.**remove\_hotkey**(hotkey\_or\_callback)
527528

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)
529530

530531

531532
Removes a previously hooked hotkey. Must be called wtih the value returned
@@ -537,7 +538,7 @@ by [`add_hotkey`](#keyboard.add_hotkey).
537538

538539
## keyboard.**unhook\_all\_hotkeys**()
539540

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)
541542

542543

543544
Removes all keyboard hotkeys in use, including abbreviations, word listeners,
@@ -549,7 +550,7 @@ Removes all keyboard hotkeys in use, including abbreviations, word listeners,
549550

550551
## keyboard.**remap\_hotkey**(src, dst, suppress=True, trigger\_on\_release=False)
551552

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)
553554

554555

555556
Whenever the hotkey `src` is pressed, suppress it and send
@@ -568,7 +569,7 @@ remap('alt+w', 'ctrl+up')
568569

569570
## keyboard.**stash\_state**()
570571

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)
572573

573574

574575
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
580581

581582
## keyboard.**restore\_state**(scan\_codes)
582583

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)
584585

585586

586587
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
592593

593594
## keyboard.**restore\_modifiers**(scan\_codes)
594595

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)
596597

597598

598599
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
603604

604605
## keyboard.**write**(text, delay=0, restore\_state\_after=True, exact=None)
605606

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)
607608

608609

609610
Sends artificial keyboard events to the OS, simulating the typing of a given
@@ -628,7 +629,7 @@ value.
628629

629630
## keyboard.**wait**(hotkey=None, suppress=False, trigger\_on\_release=False)
630631

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)
632633

633634

634635
Blocks the program execution until the given hotkey is pressed or,
@@ -640,7 +641,7 @@ if given no parameters, blocks forever.
640641

641642
## keyboard.**get\_hotkey\_name**(names=None)
642643

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)
644645

645646

646647
Returns a string representation of hotkey from the given key names, or
@@ -667,7 +668,7 @@ get_hotkey_name(['+', 'left ctrl', 'shift'])
667668

668669
## keyboard.**read\_event**(suppress=False)
669670

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)
671672

672673

673674
Blocks until a keyboard event happens, then returns that event.
@@ -678,7 +679,7 @@ Blocks until a keyboard event happens, then returns that event.
678679

679680
## keyboard.**read\_key**(suppress=False)
680681

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)
682683

683684

684685
Blocks until a keyboard event happens, then returns that event's name or,
@@ -690,7 +691,7 @@ if missing, its scan code.
690691

691692
## keyboard.**read\_hotkey**(suppress=True)
692693

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)
694695

695696

696697
Similar to [`read_key()`](#keyboard.read_key), but blocks until the user presses and releases a
@@ -711,7 +712,7 @@ read_hotkey()
711712

712713
## keyboard.**get\_typed\_strings**(events, allow\_backspace=True)
713714

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)
715716

716717

717718
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', '']
738739

739740
## keyboard.**start\_recording**(recorded\_events\_queue=None)
740741

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)
742743

743744

744745
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)`
752753

753754
## keyboard.**stop\_recording**()
754755

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)
756757

757758

758759
Stops the global recording of events and returns a list of the events
@@ -764,7 +765,7 @@ captured.
764765

765766
## keyboard.**record**(until=&#x27;escape&#x27;, suppress=False, trigger\_on\_release=False)
766767

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)
768769

769770

770771
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
781782

782783
## keyboard.**play**(events, speed\_factor=1.0)
783784

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)
785786

786787

787788
Plays a sequence of recorded events, maintaining the relative time
@@ -797,7 +798,7 @@ the end of the function.
797798

798799
## keyboard.**add\_word\_listener**(word, callback, triggers=[&#x27;space&#x27;], match\_suffix=False, timeout=2)
799800

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)
801802

802803

803804
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
821822
[`remove_word_listener(word)`](#keyboard.remove_word_listener) or [`remove_word_listener(handler)`](#keyboard.remove_word_listener).
822823

823824
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**.
825826

826827

827828

828829
<a name="keyboard.remove_word_listener"/>
829830

830831
## keyboard.**remove\_word\_listener**(word\_or\_handler)
831832

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)
833834

834835

835836
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
842843

843844
## keyboard.**add\_abbreviation**(source\_text, replacement\_text, match\_suffix=False, timeout=2)
844845

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)
846847

847848

848849
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).
865866

866867

867868

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

Comments
 (0)