HID keyboard won't release keys when called via schedule
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- embedded-iot
Research direction
Start with KeyboardInterface.send_keys and compare its behavior when called directly versus through micropython.schedule using the reproduction shown in the issue. Confirm the cause on a Pico with MicroPython 1.23.0, then verify that scheduled key presses release correctly without producing repeated input.
Written by the indexing model from the issue text.
Description
Calling KeyboardInterface().send_keys() from a function called via micropython.schedule() doesn't seem to allow keys to be released, causing a spamming issue. This code reproduces the issue:
import usb.device
from usb.device.keyboard import KeyboardInterface
from time import sleep_ms
from micropython import schedule
KBD = None
def send_keys(foo):
keys = [-0x02, 5]
print("sending keypress")
KBD.send_keys(keys)
keys.clear()
print("clearing keypress")
KBD.send_keys(keys)
def main():
global KBD
KBD = KeyboardInterface()
usb.device.get().init(KBD, builtin_driver=True)
sleep_ms(5000)
print("starting loop")
while True:
send_keys(None)
# schedule(send_keys, None)
sleep_ms(3000)
if __name__ == '__main__': main()
running schedule(send_keys, None) instead of send_keys(None) causes a flood of 🅱️, this is on a Pico running 1.23.0 and whatever the latest version of usb-device-keyboard is currently in mip.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from micropython/micropython-lib
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulty 1/5 Under an hour Newbie friendliness 72/100
micropython/micropython-lib#943 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
micropython/micropython-lib#931 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
micropython/micropython-lib#795 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#762 ·
All issues in micropython/micropython-lib
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·