English | 中文 |
---|
From a hand-wired USB & Bluetooth keyboard powered by Python to production.
The Python keyboard works so well thanks to MicroPython and CircuitPython.
Follow the guide - hand-wiring-a-keyboard.md to rapidly make a keyboard with 100 lines of Python code.
With putting more time into the Python keyboard, we find it more and more interesting. We think a Python keyboard can make a big difference, so we decide to design a new keyboard for everyone. Check out the M60 mechanical keyboard.
As the 60% keyboard lacks a lot of keys (F1~F12, arrow keys and etc). We can add features like TMK's layers and composite keys to make the small keyboard much more powerful. With the idea of Toward a more useful keyboard to keep our fingers at the home row, we can optimize the keyboard to make us more productive.
Adding the Tap-key feature, which is holding a key down to activate an alternate function, can make a big difference.
Taping d outputs d (press & release quickly), holding d down activates navigation functions.
- d + h as ←
- d + j as ↓
- d + k as ↑
- d + l as →
- d + u as PageUp
- d + n as PageDown
To apply the feature, change code.py
to:
# code.py
from keyboard import *
keyboard = Keyboard()
___ = TRANSPARENT
L1D = LAYER_TAP(1, D) # Holding D down to activate the layer #1
keyboard.keymap = (
# layer #0
(
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '-', '=', BACKSPACE,
TAB, Q, W, E, R, T, Y, U, I, O, P, '[', ']', '|',
CAPS, A, S, L1D, F, G, H, J, K, L, ';', '"', ENTER,
LSHIFT,Z, X, C, V, B, N, M, ',', '.', '/', RSHIFT,
LCTRL, LGUI, LALT, SPACE, RALT, MENU, L1, RCTRL
),
# layer #1
(
'`', F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL,
___, ___, ___, ___, ___, ___, ___,PGUP, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,LEFT,DOWN, UP,RIGHT, ___, ___, ___,
___, ___, ___, ___, ___, ___,PGDN, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___, ___
),
)
keyboard.run()
Use ; as a MODS_TAP key, taping ; outputs ;, holding ; down outputs Ctrl. To enable it, change the keymap to:
# code.py
from keyboard import *
keyboard = Keyboard()
___ = TRANSPARENT
L1D = LAYER_TAP(1, D) # D as a LAYER_TAP key
# Semicolon & Ctrl
SCC = MODS_TAP(MODS(RCTRL), ';') # ; as a MODS_TAP key
keyboard.keymap = (
# layer #0
(
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '-', '=', BACKSPACE,
TAB, Q, W, E, R, T, Y, U, I, O, P, '[', ']', '|',
CAPS, A, S, L2D, F, G, H, J, K, L, SCC, '"', ENTER,
LSHIFT,Z, X, C, V, B, N, M, ',', '.', '/', RSHIFT,
LCTRL, LGUI, LALT, SPACE, RALT, MENU, L1, RCTRL
),
# layer #1
(
'`', F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL,
___, ___, ___, ___, ___, ___, ___,PGUP, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,LEFT,DOWN, UP,RIGHT, ___, ___, ___,
___, ___, ___, ___, ___, ___,PGDN, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___, ___
),
)
keyboard.run()
Simultaneously pressing two keys (interval less than 25ms) activates an alternate function.
def pairs_handler(dev, n):
dev.send_text('You just trigger No.{} pair keys'.format(n))
keyboard.pairs_handler = pairs_handler
# Map key to number
#
# ESC 1 2 3 4 5 6 7 8 9 0 - = BACKSPACE
# TAB Q W E R T Y U I O P [ ] |
# CAPS A S D F G H J K L ; " ENTER
#LSHIFT Z X C V B N M , . / RSHIFT
# LCTRL LGUI LALT SPACE RALT MENU L1 RCTRL
#
# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
# 27,26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14,
# 28,29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
# 52,51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41,
# 53, 54, 55, 56, 57, 58, 59, 60
# Pairs: J & K
keyboard.pairs = [{35, 36}]
keyboard.run()
A C module matrix
of keyboard matrix is written to reduce latency and improve power efficiency. The module has the same function as keyboard/matrix.py
.
The module is included in the latest firmware in firmware/
. If you are interested, you can build it from circuitpython/tree/m60.
- add macro
- add cosumer keys
- add RGB backlight
- add system keys
- add mouse keys