boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.77k stars 433 forks source link

hooking extra keys #271

Open matttattoli opened 5 years ago

matttattoli commented 5 years ago

Using keyboard.hook("1") also automatically hooks the end key, "2" also hooks the down key, "3" hooks the page down key, and "4" hooks the left key.

Using Windows 10, Python 3.6.7, latest version of keyboard (0.13.3).

matttattoli commented 5 years ago

Here's a sample program that will demonstrate the error, you can replace the key 1 with the others affected.

import keyboard

def callback(kb_event):
    print(kb_event.to_json())

keyboard.hook_key('1', callback, suppress=False)
keyboard.wait()

output:

{"event_type": "down", "scan_code": 2, "name": "1", "time": 1560635769.8070629, "is_keypad": false}
{"event_type": "up", "scan_code": 2, "name": "1", "time": 1560635769.8819523, "is_keypad": false}
{"event_type": "down", "scan_code": 79, "name": "end", "time": 1560635769.9382055, "is_keypad": false}
{"event_type": "up", "scan_code": 79, "name": "end", "time": 1560635770.0160363, "is_keypad": false}