Skip to content

Commit 6cdeb91

Browse files
dhalberttannewt
authored andcommitted
1. Add docstrings to all Keycode constants. Ensure that Keycode members without docstrings will
still be listed in documentation. 2. Add Keycode.SPACE as an alias for Keycode.SPACEBAR.
1 parent 7efdc17 commit 6cdeb91

File tree

2 files changed

+62
-18
lines changed

2 files changed

+62
-18
lines changed

adafruit_hid/keycode.py

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,58 @@ class Keycode:
4646
"""
4747

4848
A = 0x04
49+
"""``a`` and ``A``"""
4950
B = 0x05
51+
"""``b`` and ``B``"""
5052
C = 0x06
53+
"""``c`` and ``C``"""
5154
D = 0x07
55+
"""``d`` and ``D``"""
5256
E = 0x08
57+
"""``e`` and ``E``"""
5358
F = 0x09
59+
"""``f`` and ``F``"""
5460
G = 0x0A
61+
"""``g`` and ``G``"""
5562
H = 0x0B
63+
"""``h`` and ``H``"""
5664
I = 0x0C
65+
"""``i`` and ``I``"""
5766
J = 0x0D
67+
"""``j`` and ``J``"""
5868
K = 0x0E
69+
"""``k`` and ``K``"""
5970
L = 0x0F
71+
"""``l`` and ``L``"""
6072
M = 0x10
73+
"""``m`` and ``M``"""
6174
N = 0x11
75+
"""``n`` and ``N``"""
6276
O = 0x12
77+
"""``o`` and ``O``"""
6378
P = 0x13
79+
"""``p`` and ``P``"""
6480
Q = 0x14
81+
"""``q`` and ``Q``"""
6582
R = 0x15
83+
"""``r`` and ``R``"""
6684
S = 0x16
85+
"""``s`` and ``S``"""
6786
T = 0x17
87+
"""``t`` and ``T``"""
6888
U = 0x18
89+
"""``u`` and ``U``"""
6990
V = 0x19
91+
"""``v`` and ``V``"""
7092
W = 0x1A
93+
"""``w`` and ``W``"""
7194
X = 0x1B
95+
"""``x`` and ``X``"""
7296
Y = 0x1C
97+
"""``y`` and ``Y``"""
7398
Z = 0x1D
99+
"""``z`` and ``Z``"""
100+
74101
ONE = 0x1E
75102
"""``1`` and ``!``"""
76103
TWO = 0x1F
@@ -102,6 +129,9 @@ class Keycode:
102129
TAB = 0x2B
103130
"""Tab and Backtab"""
104131
SPACEBAR = 0x2C
132+
"""Spacebar"""
133+
SPACE = SPACEBAR
134+
"""Alias for SPACEBAR"""
105135
MINUS = 0x2D
106136
"""``-` and ``_``"""
107137
EQUALS = 0x2E
@@ -128,6 +158,7 @@ class Keycode:
128158
"""``/`` and ``?``"""
129159

130160
CAPS_LOCK = 0x39
161+
"""Caps Lock"""
131162

132163
F1 = 0x3A
133164
"""Function key F1"""
@@ -157,33 +188,44 @@ class Keycode:
157188
PRINT_SCREEN = 0x46
158189
"""Print Screen (SysRq)"""
159190
SCROLL_LOCK = 0x47
191+
"""Scroll Lock"""
160192
PAUSE = 0x48
161193
"""Pause (Break)"""
162194

163195
INSERT = 0x49
196+
"""Insert"""
164197
HOME = 0x4A
198+
"""Home (often moves to beginning of line)"""
165199
PAGE_UP = 0x4B
200+
"""Go back one page"""
166201
DELETE = 0x4C
167-
"""Delete forward."""
202+
"""Delete forward"""
168203
END = 0x4D
204+
"""End (often moves to end of line)"""
169205
PAGE_DOWN = 0x4E
206+
"""Go forward one page"""
170207

171208
RIGHT_ARROW = 0x4F
172-
"""Moves the cursor right."""
209+
"""Move the cursor right"""
173210
LEFT_ARROW = 0x50
174-
"""Moves the cursor left."""
211+
"""Move the cursor left"""
175212
DOWN_ARROW = 0x51
176-
"""Moves the cursor down."""
213+
"""Move the cursor down"""
177214
UP_ARROW = 0x52
178-
"""Moves the cursor up."""
215+
"""Move the cursor up"""
179216

180217
KEYPAD_NUMLOCK = 0x53
181218
"""Num Lock (Clear on Mac)"""
182219
KEYPAD_FORWARD_SLASH = 0x54
220+
"""Keypad ``/``"""
183221
KEYPAD_ASTERISK = 0x55
222+
"""Keypad ``*``"""
184223
KEYPAD_MINUS = 0x56
224+
"""Keyapd ``-``"""
185225
KEYPAD_PLUS = 0x57
226+
"""Keypad ``+``"""
186227
KEYPAD_ENTER = 0x58
228+
"""Keypad Enter"""
187229
KEYPAD_ONE = 0x59
188230
"""Keypad ``1`` and End"""
189231
KEYPAD_TWO = 0x5A
@@ -193,6 +235,7 @@ class Keycode:
193235
KEYPAD_FOUR = 0x5C
194236
"""Keypad ``4`` and Left Arrow"""
195237
KEYPAD_FIVE = 0x5D
238+
"""Keypad ``5``"""
196239
KEYPAD_SIX = 0x5E
197240
"""Keypad ``6`` and Right Arrow"""
198241
KEYPAD_SEVEN = 0x5F
@@ -209,7 +252,7 @@ class Keycode:
209252
"""Keypad ``\\`` and ``|`` (Non-US)"""
210253

211254
APPLICATION = 0x65
212-
"""Application. Also known as the Menu key (Windows)."""
255+
"""Application: also known as the Menu key (Windows)"""
213256
POWER = 0x66
214257
"""Power (Mac)"""
215258
KEYPAD_EQUALS = 0x67
@@ -230,29 +273,29 @@ class Keycode:
230273
"""Function key F19 (Mac)"""
231274

232275
LEFT_CONTROL = 0xE0
233-
"""Control modifier left of the spacebar."""
276+
"""Control modifier left of the spacebar"""
234277
CONTROL = LEFT_CONTROL
235-
"""Alias for LEFT_CONTROL."""
278+
"""Alias for LEFT_CONTROL"""
236279
LEFT_SHIFT = 0xE1
237-
"""Shift modifier left of the spacebar."""
280+
"""Shift modifier left of the spacebar"""
238281
SHIFT = LEFT_SHIFT
239-
"""Alias for LEFT_SHIFT."""
282+
"""Alias for LEFT_SHIFT"""
240283
LEFT_ALT = 0xE2
241-
"""Alt modifier left of the spacebar."""
284+
"""Alt modifier left of the spacebar"""
242285
ALT = LEFT_ALT
243-
"""Alias for LEFT_ALT. Alt is also known as Option (Mac)."""
286+
"""Alias for LEFT_ALT; Alt is also known as Option (Mac)"""
244287
LEFT_GUI = 0xE3
245-
"""GUI modifier left of the spacebar."""
288+
"""GUI modifier left of the spacebar"""
246289
GUI = LEFT_GUI
247-
"""Alias for LEFT_GUI. GUI is also known as the Windows key, Command (Mac), or Meta."""
290+
"""Alias for LEFT_GUI; GUI is also known as the Windows key, Command (Mac), or Meta"""
248291
RIGHT_CONTROL = 0xE4
249-
"""Control modifier right of the spacebar."""
292+
"""Control modifier right of the spacebar"""
250293
RIGHT_SHIFT = 0xE5
251-
"""Shift modifier right of the spacebar."""
294+
"""Shift modifier right of the spacebar"""
252295
RIGHT_ALT = 0xE6
253-
"""Alt modifier right of the spacebar."""
296+
"""Alt modifier right of the spacebar"""
254297
RIGHT_GUI = 0xE7
255-
"""GUI modifier right of the spacebar."""
298+
"""GUI modifier right of the spacebar"""
256299

257300
@classmethod
258301
def modifier_bit(cls, keycode):

keycode.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ adafruit_hid.keycode
44

55
.. automodule:: adafruit_hid.keycode
66
:members:
7+
:undoc-members:
78
:member-order: bysource
89
:synopsis: keycodes for Keyboard class.
910

0 commit comments

Comments
 (0)