File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,13 @@ class Keyboard:
23
23
"""Send HID keyboard reports."""
24
24
25
25
LED_NUM_LOCK = 0x01
26
+ """LED Usage ID for Num Lock"""
26
27
LED_CAPS_LOCK = 0x02
28
+ """LED Usage ID for Caps Lock"""
27
29
LED_SCROLL_LOCK = 0x04
30
+ """LED Usage ID for Scroll Lock"""
28
31
LED_COMPOSE = 0x08
32
+ """LED Usage ID for Compose"""
29
33
30
34
# No more than _MAX_KEYPRESSES regular keys may be pressed at once.
31
35
@@ -155,5 +159,22 @@ def led_status(self):
155
159
return self ._keyboard_device .last_received_report
156
160
157
161
def led_on (self , led_code ):
158
- """Returns whether an LED is on based on the led code"""
162
+ """Returns whether an LED is on based on the led code
163
+
164
+ Examples::
165
+
166
+ import usb_hid
167
+ from adafruit_hid.keyboard import Keyboard
168
+ from adafruit_hid.keycode import Keycode
169
+ import time
170
+
171
+ # Press and release CapsLock.
172
+ kbd.press(Keycode.CAPS_LOCK)
173
+ time.sleep(.09)
174
+ kbd.release(Keycode.CAPS_LOCK)
175
+
176
+ # Check status of the LED_CAPS_LOCK
177
+ print(kbd.led_on(Keyboard.LED_CAPS_LOCK))
178
+
179
+ """
159
180
return bool (self .led_status [0 ] & led_code )
You can’t perform that action at this time.
0 commit comments