A sophisticated keyboard layout generator and management system.
kgen (Key Gen) bridges the gap between human-readable layout design and firmware-specific configurations. It allows you to define your keyboard layers in intuitive text formats and compiles them into ready to use firmware code.
- Declarative Configuration
Manage your entire keyboard through a central
config.tomland clean text-based layer files. - Visual Consistency Automatic formatting ensures your layer files remain readable and aligned with your physical layout.
- Cross-Firmware Support Generate configurations for QMK (fully supported) and ZMK (in development).
Building from source requires the Rust toolchain:
git clone https://github.com/vincbro/kgen.git
cd kgen
cargo install --path .kgen operates on a structured project directory:
config.tomlThe source of truth for your physical layout and layer definitions.- Layer Files (
.txt) Human-readable representations of individual keyboard layers.
The tool parses these inputs to generate the final keymap logic for your target firmware.
The config.toml file defines the physical architecture of your keyboard and identifies the layers to be compiled.
The layout field uses a visual grid to define key positions. Each # represents a physical key, while spaces represent gaps. This grid is used by kgen format to generate and align your layer files.
[config]
layout = [
"###### ######",
"###### ######",
"###### ######",
"######## ########",
" ##### ##### ",
"#### ####",
]The layers field lists the names of your layer files (without the .txt extension). kgen expects to find a corresponding file for each entry (e.g., base.txt, nav.txt).
layers = ["base", "nav", "sym"]Initializes a new project structure with a default configuration.
kgen init --path ./my-keyboardStandardizes the visual layout of your layer files. If a file is missing, kgen generates a template based on your configuration.
kgen format --path ./my-keyboardCompiles your project into firmware-specific source code.
kgen build --path ./my-keyboard --manufacturer qmk --output ./keymap.c| Option | Shorthand | Description | Default |
|---|---|---|---|
--path |
-p |
Path to the keyboard project directory. | Required |
--manufacturer |
-m |
Target firmware (e.g., qmk, zmk). |
qmk |
--output |
-o |
Path to save the generated output. | stdout |
kgen provides first-class support for QMK, translating text layers into robust C code compatible with standard QMK builds.
Support for ZMK is currently under active development.
To add support for a new manufacturer, please refer to the implementation patterns in src/parser/qmk.rs and extend the Manufacturers enum. Pull requests are welcome.