boppreh / keyboard

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

Cannot use scan codes to make key combinations #473

Open JimmyLienert opened 3 years ago

JimmyLienert commented 3 years ago

I am unable to use scan codes to make key combinations. I find scan codes easiest to use because some of the key names are confusing and there seems to be some overlay. However, when I try to use scan codes to make key combinations, e.g. I want keyboard.is_pressed(59+2) to make the key combination f1 and 1, it just adds the numbers, making this example result in the single key f3. I think a good solution to this issue would be to replace the plus for combinations with &, which is not used for anything in python and should not cause any issues.

SpikeVN commented 3 years ago

Just use this.

import keyboard

def your_function(args):
    # some code

keyboard.hotkey("59+2", your_function)
keyboard.wait()