After having installed KMK on the previous page, you're going to want to click 'Download Project Bundle' on the file below. Unzip the file, copy kb.py to your CIRCUITPY drive and rename main.py to code.py and copy it to the CIRCUITPY drive as well.

# SPDX-FileCopyrightText: 2022 Eva Herrada for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
import digitalio

from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.matrix import DiodeOrientation


class KMKKeyboard(_KMKKeyboard):
    led = digitalio.DigitalInOut(board.D9)
    led.direction = digitalio.Direction.OUTPUT
    led.value = False
    row_pins = (board.D10, board.MOSI, board.MISO, board.D8)
    col_pins = (
        board.D4,
        board.D7,
        board.SCK,
    )
    diode_orientation = DiodeOrientation.COLUMNS
    i2c = board.I2C

After you've copied everything over, your CIRCUITPY drive should look something like this.

Key Mapping

There are 3 different keymaps available in the files. The default one is just the nav cluster, which is the four arrow keys and the 6 nav keys. There is also a keymap designed to give you a few keys to navigate i3 quicker (you'll probably have to edit this one since I use COLEMAK as well). The third keymap is for media control.

If you want to have a specific one be the main one, move it to the top of the keyboard.keymap list in code.py. For example, if I wanted to have the media keys be active, I would edit code.py to look like this:

At this point, the keyboard should just work when you hit the keys. Feel free to mess around with the key maps. KMK has some good documentation on this process.

This guide was first published on Jan 11, 2022. It was last updated on Mar 29, 2024.

This page (Setting Up KMK) was last updated on Mar 29, 2024.

Text editor powered by tinymce.