Community Spotlight Series #3: ZMK Tools and ZMK Locale Generator
This blog continues our series of posts where we highlight projects within the ZMK ecosystem that we think are interesting and that the users might benefit from knowing about them.
In this installment, we are highlighting two projects (and a bonus one!) from Joel Spadin, a member of the core ZMK team.
The first one is ZMK Tools, a handy Visual Studio Code extension to ease working with ZMK configurations, and the second is ZMK Locale Generator, a tool to help users that use non-US English keyboard locales in their operating systems.
In the rest of the post we leave it to Joel to introduce and explain the motivations of his ZMK-related projects. Stay tuned for future installments in the series!
ZMK Tools
ZMK Tools is an extension for Visual Studio Code that helps with editing a ZMK user config repo or a fork of ZMK. I originally created it to add some code completion in .keymap
files, but then I realized that with the web version of VS Code, I could also let you set up a user config repo and build firmware, much like the user setup script, except without downloading a single thing.
User Config Setup in Browser
Here is how you can use ZMK Tools to get started with writing a ZMK keymap entirely within your browser. More detailed instructions can be found on the ZMK Tools README.
- Open the ZMK config template repo on GitHub.
- Click the Use this template button and follow the instructions to create your own repo.
- If you don't see this button, make sure you're signed in to GitHub first.
- You can name the repo anything you want, but "zmk-config" is the conventional name.
- From the GitHub page for your new repo, press . (period) and it will re-open the repo in github.dev.
- Press Ctrl + P and enter the following to install the ZMK Tools extension:
ext install spadin.zmk-tools
- Press Ctrl + Shift + P and run the ZMK: Add Keyboard command.
- Follow the prompts to select a keyboard. ZMK Tools will copy the default keymap for that keyboard if you don't already have one, and it will automatically add it to your
build.yaml
file so GitHub will build it for you.
You can then edit your .keymap
and .conf
files. Once you're done:
- Click the Source Control tab on the side bar.
- Hover over the header for the Changes list and click the
+
(Stage All Changes) button. - Write a commit message and click Commit & Push to push your changes to GitHub.
GitHub will start building the new firmware. To check the results:
- Use your browser's back button to go back to your repo's GitHub page.
- Click the Actions tab at the top of the page.
- Click the latest build (it should show the commit message you entered earlier). If it's still in progress, wait for it to finish.
- If the build was successful, go to the Artifacts section and click firmware to download the firmware. If it failed, check the error and go back to github.dev to fix it.
Keymap Code Completion
ZMK Tools also provides some basic code completion in .keymap
files. It will suggest any of ZMK's built-in behaviors inside bindings
and sensor-bindings
properties, and it will automatically add the necessary headers.
For example, with the cursor at the end of line 6 in the following keymap...
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&
>;
};
};
};
...it will suggest things such as &kp
, &mo
, etc., and upon entering one, it will recognize that #include <behaviors.dtsi>
is missing and add it to the top of the keymap:
#include <behaviors.dtsi>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&kp
>;
};
};
};
Press space after &kp
, and it will suggest all of ZMK's key codes. Upon entering one, it will again recognize that #include <dt-bindings/zmk/keys.h>
is missing and add it too:
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&kp A
>;
};
};
};
This can be very helpful for making sure you spelled key codes correctly and included all the correct headers.