File tree 2 files changed +57
-0
lines changed
2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ import time
2
+ from adafruit_hid .keyboard import Keyboard
3
+ from adafruit_hid .keycode import Keycode
4
+ import board
5
+ import digitalio
6
+
7
+ kbd = Keyboard ()
8
+
9
+ # define buttons. these can be any physical switches/buttons, but the values
10
+ # here work out-of-the-box with a CircuitPlayground Express' A and B buttons.
11
+ swap = digitalio .DigitalInOut (board .D4 )
12
+ swap .direction = digitalio .Direction .INPUT
13
+ swap .pull = digitalio .Pull .DOWN
14
+
15
+ search = digitalio .DigitalInOut (board .D5 )
16
+ search .direction = digitalio .Direction .INPUT
17
+ search .pull = digitalio .Pull .DOWN
18
+
19
+ while True :
20
+ # press ALT+TAB to swap windows
21
+ if swap .value :
22
+ kbd .press (Keycode .ALT , Keycode .TAB )
23
+ kbd .release_all ()
24
+
25
+ # press CTRL+K, which in a web browser will open the search dialog
26
+ elif search .value :
27
+ kbd .press (Keycode .CONTROL , Keycode .K )
28
+ kbd .release_all ()
29
+
30
+ time .sleep (0.1 )
Original file line number Diff line number Diff line change
1
+ import time
2
+ from adafruit_hid .mouse import Mouse
3
+ import board
4
+ import digitalio
5
+
6
+ mouse = Mouse ()
7
+
8
+ # define buttons. these can be any physical switches/buttons, but the values
9
+ # here work out-of-the-box with a CircuitPlayground Express' A and B buttons.
10
+ up = digitalio .DigitalInOut (board .D4 )
11
+ up .direction = digitalio .Direction .INPUT
12
+ up .pull = digitalio .Pull .DOWN
13
+
14
+ down = digitalio .DigitalInOut (board .D5 )
15
+ down .direction = digitalio .Direction .INPUT
16
+ down .pull = digitalio .Pull .DOWN
17
+
18
+ while True :
19
+ # scroll up one unit (varies with host/OS)
20
+ if up .value :
21
+ mouse .move (wheel = 1 )
22
+
23
+ # scroll down one unit (varies with host/OS)
24
+ elif down .value :
25
+ mouse .move (wheel = - 1 )
26
+
27
+ time .sleep (0.1 )
You can’t perform that action at this time.
0 commit comments