Different Switch Properties: Based on Structure and Sense
Tactile
Clicky
Linear
Feel
1
1
0
Hear
0
1
0
The following contents are summary of Mechanical Keyboard Knowledge Series, but excluding QKT5 - Keycaps, QKT6 - Protocol, QKT7 - Cleaning, QKT8 - Layout
Made of rubber, common in laptops. Need to push all the way in to register key press. Short distance. Cheap to make.
Rubber Domes is based on Resistor and Touch Down: 通过按压键帽从而使上下薄膜导通,且按键回弹慢,幅度小;制作成本、手感、寿命均远不如机械键盘.
Mechanics Keyboard is based on Resistor and Touch Point: 通过按下机械开关,触发其下的物理开关,从而传输信号,随后按键能够快速回弹至原始位置,且坚固耐用
There isn't real advantage to Electrostatic Capacitive Keyboard except it wears out slower with less physical feeling.
Clicky Switch
Clicky Switch Family
Clicky Switch: Special clicky mechanism on top of tactile switch to make noise.
Cherry MX Blue
Cherry MX Green
White Alps
Blue Alps
Buckling Springs (IBM Mold M and F)
Note that clicky switch make noise at the time of registering click, unlike tactile switch that only make noise when you press hard and bottom out. Therefore, clicky switch will generate noise even if you press unusually slow. Also for fast typing, tactile switch do produce noise.
Linear Switch
Linear Switch
Linear Switch: no tactile of clicky noise feedback. They just get progressingly stiffer. Gamer like because they think feedback distract them while typers don't like them because they need feedback.
Cherry MX Red
Cherry MX Black
Green Alps
Yellow Alps
Honeywell Hall-Effect
Different Switch Manufacturer
Common Manufacture: Cherry, Alps, Matias, IBM, Topre
Cherry Switch
Cherry Switch
Cherry Structure
Cherry is still in manufacture and readily avaliable. The manufacture isn't very good. Many clones of MX switches start appear in market (like Gateron)
They do no longer being made. Generally considered better feeling. They are prone to dust and easily get sticky.
Matias
Matias Switch
Matias is small keyboard manufacture making Alps switch (but not as good as original Alps). They can do backlit easily because they are transparent.
IBM
IBM Switch
Generally make Buckling Spring switch, loud but sounds fine.
Topre
Topre Switch
Very advanced tactile switch, but very very expensive.
Keyboard Controll
Rollover: how many keys you can press simultaneously to register event at the very least.
most mechanics keyboard guarantee 2KRO (two key rollover)
Ghosting: key detected when not being pressed
Ghosting "Z" when pressed "A", "S", "X" simultaneously
When pressing "A" and "S", only those two keys are detected because controller can work out the math. However, when "X" is pressed in addition to those two keys, the controller cannot tell whether "Z" or "X" or both is pressed. Therefore, controller blocks (blocking) the signal of both "Z" and "X" because we don't want to register a key we never pressed.
N-key Rollover: where the issue of ghosting and blocking don't exists, every key combination can be registered.
Achieve n-key rollover with diode for each key
Or to make keyboard that doesn't use conduction.
Capacitor
Magnetic Valve
Keycap
Keycap Sizes
Main Material
There are two main keycap material: ABS (丙烯腈丁二烯苯乙烯) and PBT (聚对苯二甲酸丁二醇酯).
Most keyboard switches are soldered into PCB, hot-reload allows to switch switches without breaking or re-solder PCB.
Key Mount PCB
Most switch has 1 central mounting point and 2 peripheral mounting point and 2 pins for signal. Hot swap is not designed for compability, but rather designed for ability to try different switches for different feeling without re-solder. Here is how hot swap switches are made.
Keyboard with Trackpoint Solution
If you want to use trackpoint with existing driver library, zmk does not support trackpoint and therefore you have to use qmk.
From https://xkcd.com/243/
There are many people who have created keyboards with trackpoints:
However, none of above mentions how exactly the Thinkpad Trackpoints are wired. Here is the documentation for all trackpoints and pin definitions. According to QMK document trackpoint (and touchpads) uses PS/2 communication just like old PS/2 mouses. The clock pin and data pin should connect to a pull-up resistor of 4.7 k\Omega as below.
There are three available modes for hooking up PS/2 devices: USART (best), interrupts (better) or busywait (not recommended).
Firmware
Although you can use STM32CubeIDE to write firmware, but QMK is a matured product and won't be re-invent the wheel. Alternatively, if you don't want to write C or C++, many people choose to write Rust: awesome-rust-keyboard-firmware
Debouncing: A mechanical switch isn't physically perfect and when the switch is pressed the contact inside the switch can "bounce" back and forth a few times which would cause multiple keypresses. Debouncing is a software solution to this effect.
Dynamic reprogramming: you can change the keymap on the board without having to flash a different firmware. On QMK boards this is done using VIA. It's a GUI tool that works similar to those programs that most people know from Corsair or Razer.
QMK
To install QMK, simply pip install qmk.
(qmk) ➜ firmware qmk setup -H /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware kokecacao/qmk_firmware
Ψ Found qmk_firmware at /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware.
Would you like to set /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware as your QMK home? [y/n] y
Ψ Wrote configuration to /home/koke_cacao/.config/qmk/qmk.ini
Ψ QMK Doctor is checking your environment.
Ψ CLI version: 1.1.0
Ψ QMK home: /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware
Ψ Detected Linux.
⚠ Missing or outdated udev rules for 'atmel-dfu' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'kiibohd' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'stm32' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'bootloadhid' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'usbasploader' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'massdrop' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Detected ModemManager without the necessary udev rules. Please either disable it or set the appropriate udev rules if you are using a Pro Micro.
⚠ Missing or outdated udev rules for 'caterina' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'hid-bootloader' boards. Run 'sudo cp /home/koke_cacao/Documents/Koke_Cacao/CAD/Workspace/kokipad/firmware/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
Ψ Git branch: master
Ψ Repo version: 0.17.5
⚠ The official repository does not seem to be configured as git remote "upstream".
☒ Can't find arm-none-eabi-gcc in your path.
☒ Can't find avr-gcc in your path.
☒ Can't find avrdude in your path.
☒ Can't find dfu-programmer in your path.
☒ Can't find dfu-util in your path.
Would you like to install dependencies? [Y/n] y
Choosing MCU for QMK
According to this guide, we can see all supported MCU in QMK's ChibiOS fork. For example, this file with #if defined(STM32F072xB) || defined(STM32F078xx) show support for STM32F072xB Chip. Although I am using STM32F072x8 (which is a low flash memory version), the two shares the same documentation, so it is also supported.
This documentation shows every option to configure QMK.
QMK Code Structure
You can think of QMK as no different from any other computer program., the entry point is a main() function in quantum/main.c. The main() initialize hardware such as USB and it runs platform_setup() and protocol_setup() depending on which platform it is compilled on. (although most of code is disabled by #define). After this, the while(true) main loop is entered.
The main loop will call protocol_task(), which in turn will call keyboard_task() in quantum/keyboard.c. This is where all the keyboard specific functionality is dispatched, and it is responsible for detecting changes in the matrix and turning status LEDs on and off.
Within keyboard_task() you'll find code to handle:
- Matrix Scanning: detect key press (99% CPU time)
- Key Mapping: mapping binary matrix to keycode defined in LAYOUT()
- Keycode Assignment: map keycode to symbols.
- Process Record: after we know the key we pressed, we run utility functions defined by client
- Mouse Handling
- Keyboard status LEDs (Caps Lock, Num Lock, Scroll Lock)
Configure QMK for Manufacturer
There are two main types of configuration files in QMK, config.h and rules.mk. These files exist at various levels in QMK and all files of the same type are combined to build the final configuration. The levels, from lowest priority to highest priority, are:
QMK Default
Keyboard: settings for specific type of keyboard regardless revision
Folders (Up to 5 levels deep): revisions
Keymap: user configuration
config.h: This is where you use define to set hardware options such as pin definitions and enable or disable options
The config.h file shouldn’t be including other config.h files, or anything besides config_common.h
rules.mk: This is a make file that is included by the top-level Makefile. It is used to set some information about the MCU that we will be compiling for as well as enabling and disabling certain features. This is important for further customization since you can include more libraries in the compiling process.
info.json: Historically QMK has been configured through a combination of two mechanisms, rules.mk and config.h. While this worked well when QMK was only a handful of keyboards we’ve grown to encompass nearly 1500 supported keyboards. That extrapolates out to 6000 configuration files under keyboards/ alone! The freeform nature of these files and the unique patterns people have used to avoid duplication have made ongoing maintenance a challenge, and a large number of our keyboards follow patterns that are outdated and sometimes harder to understand. So info.json is there to generate rules.mk and config.h.
QMK is used on a lot of different hardware. While support for the most common MCU’s and matrix configurations is built-in there are a number of drivers that can be added to a keyboard to support additional hardware. Examples include mice and other pointing devices, i/o expanders for split keyboards, bluetooth modules, and LCD, OLED, and TFT screens.
Matrix Scanning
Matrix scanning produce a binary matrix where 0 indicates non-press and 1 indicates press.
Note that the second block of LAYOUT() should match matrix scanning. However, if you look at a 17 key numpad you'll notice that it has 3 places where the matrix could have a switch but doesn't, due to larger keys. We have populated those spaces with KC_NO. (Since not KC_NO will never be triggered because no switch is connect to that specific column and row number.)
Here is an example of unusual keyboard layout mapping.
Keycode Assignment
Keycode Assignment maps physical location of key to meaningful output symbols.
Notice how all of these arguments match up with the first half of the LAYOUT() macro from the last section? This is how we take a keycode and map it to our Matrix Scan from earlier.
Keymap has maximum of 32 layers in const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS]. This is so that we can override key definition and enable function keys such as Shift, Ctrl, Fn, Opt, ...
For trivial key definitions, the higher 8 bits of the action code are all 0 and the lower 8 bits holds the USB HID usage code generated by the key as keycode.
Respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence.
The compiler can read both config.h and rules.mk as well as info.json. Therefore you can choose to write things in info.json and ignore about any configurations in config.h and rules.mk (ie. leave them blank). Reading info.json instead is called data-driven config
What you need to do:
fork qmk_firmware
make a directory in qmk_firmware/keyboards/<keyboard_name>/. You need to read directory structure
touch a qmk_firmware/keyboards/<keyboard_name>/<keyboard_name>.h and put your #pragma once and #include "quantum.h" in it.
Also put #define LAYOUT() in there if you like to write layout manually. Otherwise, convert your layout.json to info.json with QMK KLE-JSON Converter and put it in qmk_firmware/keyboards/<keyboard_name>/info.json and fill out matrix property for each key. This is your physical layout of buttons.
Fill out other parameters in info.json. These can be found here.
Note that for matrix_pins, if you use direct, you need to fill out every entry in the column with some value (can be null) to avoid errors.
Create config.h with #pragma once and #include "config_common.h" in it.
Create a directory qmk_firmware/keyboards/<keyboard_name>/keymaps/ and qmk_firmware/keyboards/<keyboard_name>/keymaps/default, touch a keymap.c in it. Write your keymap like the following. (info.json DOES NOT generate keymaps. Only the QMK Configuratior generates keymap.)
Run command qmk compile -kb kokipad -km default. The compiler error will guide your process of filling info.js.
Double check your info.js has the correct processor and correct code.
If you are flashing for the first time, you might not be able to use USB because there is not DFU program loaded.
When doing USB configurations, read this guide to choose a appropriate vendor id and product id. (Set vid=0xFEED and pid=<unique_per_keyboard>> is a good choice). Use Clueboard as an example.
Keyboard Cases
Below from 鍵盤往事 introduce ways to make keyboard cases.
Tray Mount
Tray Mount
Good:
relatively cheap
exists a case standard (where the holes and USB should go)
Bad:
unstable structure
keys must form a complete rectangle (common for 60%)
Case Mount
There isn't a standard for case mount, but usually no screw needed in PCB.
Top Frame Mount
Top Frame Mount
Bottom Mount
Bottom Mount
Sandwich Mount
Sandwich Mount
Integrated Mount
Integrated Mount
Gasket Mount
Gasket Mount
Plateless Mount
Plateless Mount
Keyboard PCB
See my github repository
Plate-mount vs PCB-mount switches
Also, here are PCB mount holes. Here is a 3D model of the switch.