1+ # You import all the IOs of your board
2+ import board
3+
4+ # These are imports from the kmk library
5+ from kmk .kmk_keyboard import KMKKeyboard
6+ from kmk .scanners .keypad import KeysScanner
7+ from kmk .keys import KC
8+ from kmk .modules .macros import Press , Release , Tap , Macros
9+
10+ # This is the main instance of your keyboard
11+ keyboard = KMKKeyboard ()
12+
13+ # Add the macro extension
14+ macros = Macros ()
15+ keyboard .modules .append (macros )
16+
17+ # Define your pins here!
18+ #PINS = [board.D3, board.D4, board.D2, board.D1]
19+ keyboard .col_pins = (board .D0 , board .D1 , board .D2 , board .D3 )
20+ keyboard .row_pins = (board .D7 , board .D8 , board .D9 , board .D10 )
21+
22+ # Tell kmk we are not using a key matrix
23+ #keyboard.matrix = KeysScanner(
24+ # pins=PINS,
25+ # value_when_pressed=False,
26+ #)
27+
28+ # Here you define the buttons corresponding to the pins
29+ # Look here for keycodes: https://github.com/KMKfw/kmk_firmware/blob/main/docs/en/keycodes.md
30+ # And here for macros: https://github.com/KMKfw/kmk_firmware/blob/main/docs/en/macros.md
31+ keyboard .keymap = [
32+ [KC .NLCK , KC .P7 , KC .P8 , KC .P9 , KC .MEDIA_PREV_TRACK ,
33+ KC .P4 , KC .P5 , KC .P6 , KC .MEDIA_PLAY_PAUSE ,
34+ KC .P1 , KC .P2 , KC .P3 , KC .MEDIA_NEXT_TRACK ,
35+ KC .P0 , KC .PDOT , KC .PENT ] # Media keys prev/next are windows-specific
36+ ]
37+
38+ # Start kmk!
39+ if __name__ == '__main__' :
40+ keyboard .go ()
0 commit comments