Skip to content

Commit

Permalink
Update changes for v0.13.3
Browse files Browse the repository at this point in the history
  • Loading branch information
boppreh committed Mar 18, 2019
1 parent 1a6982e commit c8e30d6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 40 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 0.13.3

- [Windows] Fix overflow error on Python 3.7.
- [Mac] Added alt gr -> alt mapping.
- [Mac] Added support for right shift.
- [All] Fixed numlock alias.
- [All] Fixed example code.


# 0.13.2

- [Mac] Fixed "map_name" error (i.e. implement new backend API).
Expand Down
93 changes: 53 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ key events. In this case `keyboard` will be unable to report events.
- [keyboard.**add\_word\_listener**](#keyboard.add_word_listener) *(aliases: `register_word_listener`)*
- [keyboard.**remove\_word\_listener**](#keyboard.remove_word_listener) *(aliases: `remove_abbreviation`)*
- [keyboard.**add\_abbreviation**](#keyboard.add_abbreviation) *(aliases: `register_abbreviation`)*
- [keyboard.**normalize\_name**](#keyboard.normalize_name)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L300)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L296)


Returns a list of scan codes associated with this key (name or scan code).
Expand All @@ -235,7 +236,7 @@ Returns a list of scan codes associated with this key (name or scan code).

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L330)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L326)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L363)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L359)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L396)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L392)

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

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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L400)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L396)

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

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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L404)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L400)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L431)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L427)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L441)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L437)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L472)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L468)


Invokes `callback` for every KEY_DOWN event. For details see [`hook`](#keyboard.hook).
Expand All @@ -369,7 +370,7 @@ Invokes `callback` for every KEY_DOWN event. For details see [`hook`](#keyboard.

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L478)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L474)


Invokes `callback` for every KEY_UP event. For details see [`hook`](#keyboard.hook).
Expand All @@ -380,7 +381,7 @@ Invokes `callback` for every KEY_UP event. For details see [`hook`](#keyboard.ho

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L484)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L480)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L508)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L504)


Invokes `callback` for KEY_DOWN event related to the given key. For details see [`hook`](#keyboard.hook).
Expand All @@ -407,7 +408,7 @@ Invokes `callback` for KEY_DOWN event related to the given key. For details see

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L514)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L510)


Invokes `callback` for KEY_UP event related to the given key. For details see [`hook`](#keyboard.hook).
Expand All @@ -418,7 +419,7 @@ Invokes `callback` for KEY_UP event related to the given key. For details see [`

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L520)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L516)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L528)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L524)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L539)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L536)


Suppresses all key events of the given key, regardless of modifiers.
Expand All @@ -453,7 +454,7 @@ Suppresses all key events of the given key, regardless of modifiers.

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L546)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L543)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L560)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L557)


Parses a user-provided hotkey. Differently from [`parse_hotkey`](#keyboard.parse_hotkey),
Expand All @@ -478,7 +479,7 @@ each step is a list of all possible combinations of those scan codes.

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L600)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L597)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L746)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L743)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L754)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L751)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L765)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L762)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L785)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L782)


Builds a list of all currently pressed scan codes, releases them and returns
Expand All @@ -580,7 +581,7 @@ the list. Pairs well with [`restore_state`](#keyboard.restore_state) and [`resto

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L797)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L794)


Given a list of scan_codes ensures these keys, and only these keys, are
Expand All @@ -592,7 +593,7 @@ pressed. Pairs well with [`stash_state`](#keyboard.stash_state), alternative to

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L814)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L811)


Like [`restore_state`](#keyboard.restore_state), but only restores modifier keys.
Expand All @@ -603,7 +604,7 @@ Like [`restore_state`](#keyboard.restore_state), but only restores modifier keys

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L820)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L817)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L875)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L872)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L889)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L886)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L920)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L917)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L931)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L928)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L939)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L936)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L961)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L958)


Given a sequence of events, tries to deduce what strings were typed.
Expand All @@ -738,7 +739,7 @@ get_type_strings(record()) #-> ['This is what', 'I recorded', '']

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1006)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1005)


Starts recording all keyboard events into a global variable, or the given
Expand All @@ -752,7 +753,7 @@ Use [`stop_recording()`](#keyboard.stop_recording) or [`unhook(hooked_function)`

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1018)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1017)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1030)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1029)


Records all keyboard events from all keyboards until the user presses the
Expand All @@ -781,7 +782,7 @@ Note: for more details on the keyboard hook and events see [`hook`](#keyboard.ho

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1044)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1043)


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

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1068)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1067)


Invokes a callback every time a sequence of characters is typed (e.g. 'pet')
Expand All @@ -821,15 +822,15 @@ Returns the event handler created. To remove a word listener use
[`remove_word_listener(word)`](#keyboard.remove_word_listener) or [`remove_word_listener(handler)`](#keyboard.remove_word_listener).

Note: all actions are performed on key down. Key up events are ignored.
Note: word matches are **case sensitive**.
Note: word mathes are **case sensitive**.



<a name="keyboard.remove_word_listener"/>

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1124)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1123)


Removes a previously registered word listener. Accepts either the word used
Expand All @@ -842,7 +843,7 @@ during registration (exact string) or the event handler returned by the

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

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1132)
[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L1131)


Registers a hotkey that replaces one typed text with another. For example
Expand All @@ -865,3 +866,15 @@ For more details see [`add_word_listener`](#keyboard.add_word_listener).



<a name="keyboard.normalize_name"/>

## keyboard.**normalize\_name**(name)

[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/_canonical_names.py#L1233)


Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to
the canonical representation (e.g. "left ctrl") if one is known.



0 comments on commit c8e30d6

Please sign in to comment.