Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb/usb-device-keyboard: Add key release. #892

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion micropython/usb/usb-device-keyboard/manifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
metadata(version="0.1.0")
metadata(version="0.1.1")
require("usb-device-hid")
package("usb")
16 changes: 16 additions & 0 deletions micropython/usb/usb-device-keyboard/usb/device/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ def send_keys(self, down_keys, timeout_ms=100):
return True
return False

def release_all(self):
for i in range(_KEY_REPORT_LEN):
self._key_reports[0][i] = 0
if self.send_report(self._key_reports[0], 200):
return True
return False

"""Example usage

k = KeyboardInterface()
usb.device.get().init(k, builtin_driver=True)
key = [4] #It clicks letter A (refer KeyCode class)
k.send_keys(key)
k.release_all()
"""


# HID keyboard report descriptor
#
Expand Down
Loading