From da6945d9c700ab5375e5672d2e5aaa41f47bdb55 Mon Sep 17 00:00:00 2001 From: BoppreH Date: Sun, 13 Nov 2016 17:06:10 +0100 Subject: [PATCH 1/2] Add simple installation instructions --- README.md | 58 +++++++++++++++++++++++--------------------- keyboard/__init__.py | 2 ++ 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 355a3ae4..949262c5 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Take full control of your keyboard with this small Python library. Hook global e **API docs**: https://github.com/boppreh/keyboard#api +**Installation**: `pip install keyboard` + - Global event hook on all keyboards (captures keys regardless of focus). - **Listen** and **sends** keyboard events. - Works with **Windows** and **Linux** (requires sudo). @@ -124,7 +126,7 @@ This program makes no attempt to hide itself, so don't use it for keyloggers. ## keyboard.**matches**(event, name) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L84) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L86) Returns True if the given event represents the same key as the one given in @@ -135,7 +137,7 @@ Returns True if the given event represents the same key as the one given in ## keyboard.**is\_pressed**(key) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L101) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L103) Returns True if the key is pressed. @@ -149,7 +151,7 @@ Returns True if the key is pressed. ## keyboard.**canonicalize**(hotkey) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L123) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L125) Splits a user provided hotkey into a list of steps, each one made of a list @@ -170,7 +172,7 @@ more than one physical key (e.g. two 'ctrl' keys). ## keyboard.**call\_later**(fn, args=(), delay=0.001) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L157) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L159) Calls the provided function in a new thread after waiting some time. @@ -182,7 +184,7 @@ the current execution flow. ## keyboard.**clear\_all\_hotkeys**() -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L166) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L168) Removes all hotkey handlers. Note some functions such as 'wait' and 'record' @@ -202,7 +204,7 @@ Alias for `clear_all_hotkeys`. ## keyboard.**add\_hotkey**(hotkey, callback, args=(), blocking=True, timeout=1) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L181) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L183) Invokes a callback every time a key combination is pressed. The hotkey must @@ -244,7 +246,7 @@ Alias for `add_hotkey`. ## keyboard.**hook**(callback) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L246) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L248) Installs a global listener on all available keyboards, invoking `callback` @@ -266,7 +268,7 @@ Returns the given callback for easier development. ## keyboard.**unhook**(callback) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L265) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L267) Removes a previously hooked callback. @@ -274,7 +276,7 @@ Removes a previously hooked callback. ## keyboard.**unhook\_all**() -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L269) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L271) Removes all keyboard hooks in use, including hotkeys, abbreviations, word @@ -285,7 +287,7 @@ listeners, [`record`](#keyboard.record)ers and [`wait`](#keyboard.wait)s. ## keyboard.**hook\_key**(key, keydown\_callback=<lambda>, keyup\_callback=<lambda>) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L278) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L280) Hooks key up and key down events for a single key. Returns the event handler @@ -300,7 +302,7 @@ affects it aswell. ## keyboard.**on\_press**(callback) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L299) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L301) Invokes `callback` for every KEY_DOWN event. For details see [`hook`](#keyboard.hook). @@ -310,7 +312,7 @@ Invokes `callback` for every KEY_DOWN event. For details see [`hook`](#keyboard. ## keyboard.**on\_release**(callback) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L305) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L307) Invokes `callback` for every KEY_UP event. For details see [`hook`](#keyboard.hook). @@ -320,7 +322,7 @@ Invokes `callback` for every KEY_UP event. For details see [`hook`](#keyboard.ho ## keyboard.**remove\_hotkey**(hotkey\_or\_handler) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L332) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L334) Removes a previously registered hotkey. Accepts either the hotkey used @@ -338,7 +340,7 @@ Alias for `remove_hotkey`. ## keyboard.**add\_word\_listener**(word, callback, triggers=['space'], match\_suffix=False, timeout=2) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L344) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L346) Invokes a callback every time a sequence of characters is typed (e.g. 'pet') @@ -375,7 +377,7 @@ Alias for `add_word_listener`. ## keyboard.**remove\_word\_listener**(word\_or\_handler) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L395) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L397) Removes a previously registered word listener. Accepts either the word used @@ -393,7 +395,7 @@ Alias for `remove_word_listener`. ## keyboard.**add\_abbreviation**(source\_text, replacement\_text, match\_suffix=True, timeout=2) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L403) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L405) Registers a hotkey that replaces one typed text with another. For example @@ -422,7 +424,7 @@ Alias for `add_abbreviation`. ## keyboard.**stash\_state**() -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L429) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L431) Builds a list of all currently pressed scan codes, releases them and returns @@ -433,7 +435,7 @@ the list. Pairs well with [`restore_state`](#keyboard.restore_state). ## keyboard.**restore\_state**(scan\_codes) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L439) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L441) Given a list of scan_codes ensures these keys, and only these keys, are @@ -444,7 +446,7 @@ pressed. Pairs well with [`stash_state`](#keyboard.stash_state). ## keyboard.**write**(text, delay=0, restore\_state\_after=True) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L451) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L453) Sends artificial keyboard events to the OS, simulating the typing of a given @@ -465,7 +467,7 @@ beginning. Defaults to True. ## keyboard.**to\_scan\_code**(key) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L494) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L496) Returns the scan code for a given key name (or scan code, i.e. do nothing). @@ -477,7 +479,7 @@ one of the scan codes will be chosen. ## keyboard.**send**(combination, do\_press=True, do\_release=True) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L506) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L508) Sends OS events that perform the given hotkey combination. @@ -499,7 +501,7 @@ Note: keys are released in the opposite order they were pressed. ## keyboard.**press**(combination) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L531) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L533) Presses and holds down a key combination (see [`send`](#keyboard.send)). @@ -507,7 +509,7 @@ Presses and holds down a key combination (see [`send`](#keyboard.send)). ## keyboard.**release**(combination) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L535) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L537) Releases a key combination (see [`send`](#keyboard.send)). @@ -515,7 +517,7 @@ Releases a key combination (see [`send`](#keyboard.send)). ## keyboard.**press\_and\_release**(combination) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L539) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L541) Presses and releases the key combination (see [`send`](#keyboard.send)). @@ -523,7 +525,7 @@ Presses and releases the key combination (see [`send`](#keyboard.send)). ## keyboard.**wait**(combination) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L543) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L545) Blocks the program execution until the given key combination is pressed. @@ -533,7 +535,7 @@ Blocks the program execution until the given key combination is pressed. ## keyboard.**record**(until='escape') -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L553) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L555) Records all keyboard events from all keyboards until the user presses the @@ -549,7 +551,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#L569) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L571) Plays a sequence of recorded events, maintaining the relative time @@ -570,7 +572,7 @@ Alias for `play`. ## keyboard.**get\_typed\_strings**(events, allow\_backspace=True) -[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L597) +[\[source\]](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L599) Given a sequence of events, tries to deduce what strings were typed. diff --git a/keyboard/__init__.py b/keyboard/__init__.py index 226ed81e..fcd2cb76 100644 --- a/keyboard/__init__.py +++ b/keyboard/__init__.py @@ -7,6 +7,8 @@ **API docs**: https://github.com/boppreh/keyboard#api +**Installation**: `pip install keyboard` + - Global event hook on all keyboards (captures keys regardless of focus). - **Listen** and **sends** keyboard events. - Works with **Windows** and **Linux** (requires sudo). From c758147bd2c9c0a3a2aafb3ec7a8e9fe67ae68d6 Mon Sep 17 00:00:00 2001 From: BoppreH Date: Sun, 13 Nov 2016 19:45:16 +0100 Subject: [PATCH 2/2] Add linux device attribute and windows keypad attribute --- keyboard/_keyboard_event.py | 4 +- keyboard/_nixcommon.py | 2 +- keyboard/_nixkeyboard.py | 4 +- keyboard/_nixmouse.py | 2 +- keyboard/_winkeyboard.py | 322 ++++++++++++++++++------------------ 5 files changed, 169 insertions(+), 165 deletions(-) diff --git a/keyboard/_keyboard_event.py b/keyboard/_keyboard_event.py index 958c758c..e128ea32 100644 --- a/keyboard/_keyboard_event.py +++ b/keyboard/_keyboard_event.py @@ -16,10 +16,12 @@ class KeyboardEvent(object): name = None time = None - def __init__(self, event_type, scan_code, name=None, time=None): + def __init__(self, event_type, scan_code, name=None, time=None, device=None, is_keypad=None): self.event_type = event_type self.scan_code = scan_code self.time = now() if time is None else time + self.device = device + self.is_keypad = is_keypad if name: self.name = normalize_name(name) diff --git a/keyboard/_nixcommon.py b/keyboard/_nixcommon.py index f813a191..e31e4613 100644 --- a/keyboard/_nixcommon.py +++ b/keyboard/_nixcommon.py @@ -83,7 +83,7 @@ def output_file(self): def read_event(self): data = self.input_file.read(struct.calcsize(event_bin_format)) seconds, microseconds, type, code, value = struct.unpack(event_bin_format, data) - return (seconds + microseconds / 1e6, type, code, value) + return seconds + microseconds / 1e6, type, code, value, self.path def write_event(self, type, code, value): integer, fraction = divmod(now(), 1) diff --git a/keyboard/_nixkeyboard.py b/keyboard/_nixkeyboard.py index 98f6d285..1443c415 100644 --- a/keyboard/_nixkeyboard.py +++ b/keyboard/_nixkeyboard.py @@ -108,7 +108,7 @@ def listen(queue): build_tables() while True: - time, type, code, value = device.read_event() + time, type, code, value, device = device.read_event() if type != EV_KEY: continue @@ -126,7 +126,7 @@ def listen(queue): else: pressed_modifiers.discard(name) - queue.put(KeyboardEvent(event_type, scan_code, name, time)) + queue.put(KeyboardEvent(event_type=event_type, scan_code=scan_code, name=name, time=time, device=device)) def write_event(scan_code, is_down): build_device() diff --git a/keyboard/_nixmouse.py b/keyboard/_nixmouse.py index 7018c843..b8d81168 100644 --- a/keyboard/_nixmouse.py +++ b/keyboard/_nixmouse.py @@ -75,7 +75,7 @@ def listen(queue): build_device() while True: - time, type, code, value = device.read_event() + time, type, code, value, device = device.read_event() if type == EV_SYN or type == EV_MSC: continue diff --git a/keyboard/_winkeyboard.py b/keyboard/_winkeyboard.py index a8e439f1..db91d464 100644 --- a/keyboard/_winkeyboard.py +++ b/keyboard/_winkeyboard.py @@ -29,7 +29,8 @@ class KBDLLHOOKSTRUCT(Structure): _fields_ = [("vk_code", DWORD), ("scan_code", DWORD), ("flags", DWORD), - ("time", c_int),] + ("time", c_int), + ("dwExtraInfo", ULONG_PTR)] class MOUSEINPUT(ctypes.Structure): _fields_ = (('dx', LONG), @@ -129,164 +130,164 @@ class INPUT(ctypes.Structure): } virtual_key_to_name = { -0x03: 'control-break processing', -0x08: 'backspace', -0x09: 'tab', -0x0c: 'clear', -0x0d: 'enter', -0x10: 'shift', -0x11: 'ctrl', -0x12: 'alt', -0x13: 'pause', -0x14: 'caps lock', -0x15: 'ime kana mode', -0x15: 'ime hanguel mode', -0x15: 'ime hangul mode', -0x17: 'ime junja mode', -0x18: 'ime final mode', -0x19: 'ime hanja mode', -0x19: 'ime kanji mode', -0x1b: 'esc', -0x1c: 'ime convert', -0x1d: 'ime nonconvert', -0x1e: 'ime accept', -0x1f: 'ime mode change request', -0x20: 'spacebar', -0x21: 'page up', -0x22: 'page down', -0x23: 'end', -0x24: 'home', -0x25: 'left arrow', -0x26: 'up arrow', -0x27: 'right arrow', -0x28: 'down arrow', -0x29: 'select', -0x2a: 'print', -0x2b: 'execute', -0x2c: 'print screen', -0x2d: 'ins', -0x2e: 'del', -0x2f: 'help', -0x30: '0', -0x31: '1', -0x32: '2', -0x33: '3', -0x34: '4', -0x35: '5', -0x36: '6', -0x37: '7', -0x38: '8', -0x39: '9', -0x41: 'a', -0x42: 'b', -0x43: 'c', -0x44: 'd', -0x45: 'e', -0x46: 'f', -0x47: 'g', -0x48: 'h', -0x49: 'i', -0x4a: 'j', -0x4b: 'k', -0x4c: 'l', -0x4d: 'm', -0x4e: 'n', -0x4f: 'o', -0x50: 'p', -0x51: 'q', -0x52: 'r', -0x53: 's', -0x54: 't', -0x55: 'u', -0x56: 'v', -0x57: 'w', -0x58: 'x', -0x59: 'y', -0x5a: 'z', -0x5b: 'windows', -0x5c: 'windows', -0x5d: 'applications', -0x5f: 'sleep', -0x60: '0', -0x61: '1', -0x62: '2', -0x63: '3', -0x64: '4', -0x65: '5', -0x66: '6', -0x67: '7', -0x68: '8', -0x69: '9', -0x6a: 'multiply', -0x6b: 'add', -0x6c: 'separator', -0x6d: 'subtract', -0x6e: 'decimal', -0x6f: 'divide', -0x70: 'f1', -0x71: 'f2', -0x72: 'f3', -0x73: 'f4', -0x74: 'f5', -0x75: 'f6', -0x76: 'f7', -0x77: 'f8', -0x78: 'f9', -0x79: 'f10', -0x7a: 'f11', -0x7b: 'f12', -0x7c: 'f13', -0x7d: 'f14', -0x7e: 'f15', -0x7f: 'f16', -0x80: 'f17', -0x81: 'f18', -0x82: 'f19', -0x83: 'f20', -0x84: 'f21', -0x85: 'f22', -0x86: 'f23', -0x87: 'f24', -0x90: 'num lock', -0x91: 'scroll lock', -0xa0: 'left shift', -0xa1: 'right shift', -0xa2: 'left control', -0xa3: 'right control', -0xa4: 'left menu', -0xa5: 'right menu', -0xa6: 'browser back', -0xa7: 'browser forward', -0xa8: 'browser refresh', -0xa9: 'browser stop', -0xaa: 'browser search key ', -0xab: 'browser favorites', -0xac: 'browser start and home', -0xad: 'volume mute', -0xae: 'volume down', -0xaf: 'volume up', -0xb0: 'next track', -0xb1: 'previous track', -0xb2: 'stop media', -0xb3: 'play/pause media', -0xb4: 'start mail', -0xb5: 'select media', -0xb6: 'start application 1', -0xb7: 'start application 2', -0xbb: '+', -0xbc: ',', -0xbd: '-', -0xbe: '.', -0xe5: 'ime process', -0xf6: 'attn', -0xf7: 'crsel', -0xf8: 'exsel', -0xf9: 'erase eof', -0xfa: 'play', -0xfb: 'zoom', -0xfc: 'reserved ', -0xfd: 'pa1', -0xfe: 'clear', + 0x03: 'control-break processing', + 0x08: 'backspace', + 0x09: 'tab', + 0x0c: 'clear', + 0x0d: 'enter', + 0x10: 'shift', + 0x11: 'ctrl', + 0x12: 'alt', + 0x13: 'pause', + 0x14: 'caps lock', + 0x15: 'ime kana mode', + 0x15: 'ime hanguel mode', + 0x15: 'ime hangul mode', + 0x17: 'ime junja mode', + 0x18: 'ime final mode', + 0x19: 'ime hanja mode', + 0x19: 'ime kanji mode', + 0x1b: 'esc', + 0x1c: 'ime convert', + 0x1d: 'ime nonconvert', + 0x1e: 'ime accept', + 0x1f: 'ime mode change request', + 0x20: 'spacebar', + 0x21: 'page up', + 0x22: 'page down', + 0x23: 'end', + 0x24: 'home', + 0x25: 'left arrow', + 0x26: 'up arrow', + 0x27: 'right arrow', + 0x28: 'down arrow', + 0x29: 'select', + 0x2a: 'print', + 0x2b: 'execute', + 0x2c: 'print screen', + 0x2d: 'ins', + 0x2e: 'del', + 0x2f: 'help', + 0x30: '0', + 0x31: '1', + 0x32: '2', + 0x33: '3', + 0x34: '4', + 0x35: '5', + 0x36: '6', + 0x37: '7', + 0x38: '8', + 0x39: '9', + 0x41: 'a', + 0x42: 'b', + 0x43: 'c', + 0x44: 'd', + 0x45: 'e', + 0x46: 'f', + 0x47: 'g', + 0x48: 'h', + 0x49: 'i', + 0x4a: 'j', + 0x4b: 'k', + 0x4c: 'l', + 0x4d: 'm', + 0x4e: 'n', + 0x4f: 'o', + 0x50: 'p', + 0x51: 'q', + 0x52: 'r', + 0x53: 's', + 0x54: 't', + 0x55: 'u', + 0x56: 'v', + 0x57: 'w', + 0x58: 'x', + 0x59: 'y', + 0x5a: 'z', + 0x5b: 'windows', + 0x5c: 'windows', + 0x5d: 'applications', + 0x5f: 'sleep', + 0x60: '0', + 0x61: '1', + 0x62: '2', + 0x63: '3', + 0x64: '4', + 0x65: '5', + 0x66: '6', + 0x67: '7', + 0x68: '8', + 0x69: '9', + 0x6a: 'multiply', + 0x6b: 'add', + 0x6c: 'separator', + 0x6d: 'subtract', + 0x6e: 'decimal', + 0x6f: 'divide', + 0x70: 'f1', + 0x71: 'f2', + 0x72: 'f3', + 0x73: 'f4', + 0x74: 'f5', + 0x75: 'f6', + 0x76: 'f7', + 0x77: 'f8', + 0x78: 'f9', + 0x79: 'f10', + 0x7a: 'f11', + 0x7b: 'f12', + 0x7c: 'f13', + 0x7d: 'f14', + 0x7e: 'f15', + 0x7f: 'f16', + 0x80: 'f17', + 0x81: 'f18', + 0x82: 'f19', + 0x83: 'f20', + 0x84: 'f21', + 0x85: 'f22', + 0x86: 'f23', + 0x87: 'f24', + 0x90: 'num lock', + 0x91: 'scroll lock', + 0xa0: 'left shift', + 0xa1: 'right shift', + 0xa2: 'left control', + 0xa3: 'right control', + 0xa4: 'left menu', + 0xa5: 'right menu', + 0xa6: 'browser back', + 0xa7: 'browser forward', + 0xa8: 'browser refresh', + 0xa9: 'browser stop', + 0xaa: 'browser search key ', + 0xab: 'browser favorites', + 0xac: 'browser start and home', + 0xad: 'volume mute', + 0xae: 'volume down', + 0xaf: 'volume up', + 0xb0: 'next track', + 0xb1: 'previous track', + 0xb2: 'stop media', + 0xb3: 'play/pause media', + 0xb4: 'start mail', + 0xb5: 'select media', + 0xb6: 'start application 1', + 0xb7: 'start application 2', + 0xbb: '+', + 0xbc: ',', + 0xbd: '-', + 0xbe: '.', + 0xe5: 'ime process', + 0xf6: 'attn', + 0xf7: 'crsel', + 0xf8: 'exsel', + 0xf9: 'erase eof', + 0xfa: 'play', + 0xfb: 'zoom', + 0xfc: 'reserved ', + 0xfd: 'pa1', + 0xfe: 'clear', } from_scan_code = {} @@ -392,7 +393,8 @@ def low_level_keyboard_handler(nCode, wParam, lParam): shift_is_pressed = True elif event_type == KEY_UP and name == 'shift': shift_is_pressed = False - queue.put(KeyboardEvent(event_type, scan_code, name)) + + queue.put(KeyboardEvent(event_type=event_type, scan_code=scan_code, name=name, is_keypad=is_keypad)) return ret