Skip to content

feat: Export keymap as ZMK .keymap file snippet#63

Draft
cormoran with Copilot wants to merge 2 commits into
mainfrom
copilot/export-current-keymap-feature
Draft

feat: Export keymap as ZMK .keymap file snippet#63
cormoran with Copilot wants to merge 2 commits into
mainfrom
copilot/export-current-keymap-feature

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Adds a popup export dialog on the Keymap page that generates a ZMK DTS .keymap snippet from the current in-memory keymap, with a copy-to-clipboard button.

Changes

  • src/lib/zmkExport.ts — Core export logic:

    • getZMKKeycodeName(hidUsage) — HID usage → ZMK keycode name (letters, N1N0 number row, F1F24, modifiers, consumer/media, modifier wrapping e.g. LS(A))
    • bindingToZMKString(binding, behavior) — binding → ZMK DTS token (&kp A, &mo 1, &lt 1 A, &bt BT_CLR, &out OUT_USB, &mkp LCLK, &mmv MOVE_UP, etc.)
    • generateZMKKeymapContent(params) — assembles full / { keymap { ... } } block; groups bindings into rows by physical key Y position; includes sensor-bindings when sensor data provided
  • src/components/KeymapExportDialog.tsx — Radix Dialog showing the generated snippet in a monospace block with copy button (Copied / Copy failed feedback states)

  • src/pages/KeymapPage.tsx — Export button added to action bar when connected; exportContent computed via useMemo

Example output

/ {
    keymap {
        compatible = "zmk,keymap";
        Base {
            display-name = "Base";
            bindings = <
                &kp Q &kp W &kp E &kp R &kp T
                &kp A &kp S &kp D &kp F &kp G
            >;
            sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>;
        };
        Lower {
            display-name = "Lower";
            bindings = <
                &trans &trans &trans &trans &trans
                &bt BT_CLR &bt BT_SEL 0 &trans &trans &trans
            >;
        };
    };
};

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: cormoran <7994064+cormoran@users.noreply.github.com>
Copilot AI changed the title [WIP] Add feature to export current keymap in ZMK format feat: Export keymap as ZMK .keymap file snippet Feb 20, 2026
Copilot AI requested a review from cormoran February 20, 2026 14:04
@github-actions

Copy link
Copy Markdown

🚀 Cloudflare Workers Preview

Preview URL: https://9e056093-dya-studio.cormoran707.workers.dev

Deployed from commit 572cbbe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants