import keyboard as kb
keys=["space","volume mute",
"volume down",
"volume up",
"next track",
"previous track",
"play/pause media"]
for key in keys:
kb.add_hotkey(key,lambda key=key:print(f'{key} pressed!'))
while True:
event = kb.read_event()
print(event)
Activating any of the listed media keys are read as events in the loop:
KeyboardEvent(volume up down)
KeyboardEvent(volume up up)
...etc
(Similar output for new_core branch)
But the assigned hotkeys above are not triggered. Just to make sure hotkeys are working in general, I added space, and that does trigger the hotkey when pressed.
Tested on current pypi version, as well as new_core branch 0bd72225fdb60fe3679cd90bb30e56eaae2cc183
Tested on Win10 desktop with Steelseries Apex 7 w/ "scroll-wheel" volume control, and Win10 Asus laptop with dedicated vol up/down keys
Tried:
Running the script as administrator
Binding other keys to vol up/down (in case the wheel was doing something weird)
Possibly related to the Windows volume/media control popup? That shows up even if I set suppress=True in the hotkey (even when running as admin)
With the following code:
Activating any of the listed media keys are read as events in the loop:
(Similar output for
new_core
branch) But the assigned hotkeys above are not triggered. Just to make sure hotkeys are working in general, I addedspace
, and that does trigger the hotkey when pressed. Tested on current pypi version, as well asnew_core
branch 0bd72225fdb60fe3679cd90bb30e56eaae2cc183 Tested on Win10 desktop with Steelseries Apex 7 w/ "scroll-wheel" volume control, and Win10 Asus laptop with dedicated vol up/down keys Tried:Possibly related to the Windows volume/media control popup? That shows up even if I set
suppress=True
in the hotkey (even when running as admin)