{"id":35478210,"url":"https://github.com/rafaelromao/zmk-layer-morph","last_synced_at":"2026-01-13T22:02:57.799Z","repository":{"id":331369554,"uuid":"1121882483","full_name":"rafaelromao/zmk-layer-morph","owner":"rafaelromao","description":"The Layer Morph behavior morphs a keypress based on whether a given layer is active. ","archived":false,"fork":false,"pushed_at":"2026-01-03T17:26:48.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-07T02:47:49.034Z","etag":null,"topics":["behaviour","layer","morph","zmk"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafaelromao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-23T18:00:09.000Z","updated_at":"2026-01-05T14:25:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rafaelromao/zmk-layer-morph","commit_stats":null,"previous_names":["rafaelromao/zmk-layer-morph"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rafaelromao/zmk-layer-morph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelromao%2Fzmk-layer-morph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelromao%2Fzmk-layer-morph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelromao%2Fzmk-layer-morph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelromao%2Fzmk-layer-morph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafaelromao","download_url":"https://codeload.github.com/rafaelromao/zmk-layer-morph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelromao%2Fzmk-layer-morph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28399379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behaviour","layer","morph","zmk"],"created_at":"2026-01-03T13:14:39.265Z","updated_at":"2026-01-13T22:02:57.792Z","avatar_url":"https://github.com/rafaelromao.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZMK Layer Morph Behavior\n\nThe Layer Morph behavior morphs a keypress based on whether a given layer is active.\n\n## Usage\n\nTo load the module, add the following entries to remotes and projects in config/west.yml.\n\n```dts\nmanifest:\n  remotes:\n    - name: zmkfirmware\n      url-base: https://github.com/zmkfirmware\n    - name: rafaelromao\n      url-base: https://github.com/rafaelromao\n  projects:\n    - name: zmk\n      remote: zmkfirmware\n      revision: v0.3\n      import: app/west.yml\n    - name: zmk-layer-morph\n      remote: rafaelromao\n      revision: v0.3 # set to same as ZMK version above\n  self:\n    path: config\n```\n\n## Devicetree Binding\n\nTo use the layer morph behavior, you need to define it in your keymap file.\n\n### Properties\n\n- `bindings`: A phandle-array of two bindings. The first binding is the \"normal\" binding, and the second is the \"morphed\" binding.\n- `layers`: The layer (or layers) to check for. If any of the specified layers are active, the morphed binding will be used. Can be a single layer like `\u003c1\u003e` or a list of layers like `\u003c1 2\u003e`.\n\n### Example\n\nHere is an example of how to define a layer morph behavior in your `.keymap` file:\n\n```dts\n/ {\n    behaviors {\n        // Define the layer-morph behavior\n        my_layer_morph: layer_morph {\n            compatible = \"zmk,behavior-layer-morph\";\n            #binding-cells = \u003c0\u003e;\n            // The layers to check for (e.g., layers 1 and 2)\n            layers = \u003c1 2\u003e;\n            // The bindings for the normal and morphed keys\n            // Normal: 'A', Morphed: 'B'\n            bindings = \u003c\u0026kp A\u003e, \u003c\u0026kp B\u003e;\n        };\n    };\n\n    keymap {\n        compatible = \"zmk,keymap\";\n\n        default_layer {\n            bindings = \u003c\u0026my_layer_morph\u003e;\n        };\n    };\n};\n```\n\nIn this example, pressing the key will send `A`. If layer `1` or layer `2` is active, it will send `B` instead.\n\n## Advanced Example: MacOS and Linux Layers\n\nThis example shows how to use the layer morph behavior to create a keymap that works for both MacOS and Linux.\n\nThe keymap has a default base layer for MacOS, and a secondary base layer for Linux that can be toggled on. A third layer contains shortcuts for copy and paste that will behave differently depending on whether the Linux layer is active.\n\n```dts\n/ {\n    // Define layer names for clarity\n    // 0: MacOS (default)\n    // 1: Linux\n    // 2: Shortcuts\n    \n    behaviors {\n        // Layer morph for copy\n        lm_copy: layer_morph_copy {\n            compatible = \"zmk,behavior-layer-morph\";\n            #binding-cells = \u003c0\u003e;\n            layers = \u003c1\u003e; // Check for Linux layer\n            bindings = \u003c\u0026kp LG(C)\u003e, \u003c\u0026kp LC(C)\u003e; // MacOS, Linux\n        };\n\n        // Layer morph for paste\n        lm_paste: layer_morph_paste {\n            compatible = \"zmk,behavior-layer-morph\";\n            #binding-cells = \u003c0\u003e;\n            layers = \u003c1\u003e; // Check for Linux layer\n            bindings = \u003c\u0026kp LG(V)\u003e, \u003c\u0026kp LC(V)\u003e; // MacOS, Linux\n        };\n    };\n\n    keymap {\n        compatible = \"zmk,keymap\";\n\n        macos_layer {\n            bindings = \u003c\n                \u0026kp A  \u0026kp B  \u0026tog 1    \u0026mo 2\n            \u003e;\n        };\n\n        linux_layer {\n            bindings = \u003c\n                \u0026trans \u0026trans \u0026tog 1    \u0026mo 2\n            \u003e;\n        };\n\n        shortcuts_layer {\n            bindings = \u003c\n                \u0026lm_copy \u0026lm_paste \u0026trans   \u0026trans\n            \u003e;\n        };\n    };\n};\n```\n\n### How it Works\n\n1.  **Layers:**\n    -   The `macos_layer` is the default layer (layer 0).\n    -   The `linux_layer` is layer 1.\n    -   The `shortcuts_layer` is layer 2.\n\n2.  **Layer Switching:**\n    -   On any of the base layers, pressing the third key (`\u0026tog 1`) toggles the `linux_layer` on or off.\n    -   Pressing and holding the fourth key (`\u0026mo 2`) momentarily activates the `shortcuts_layer`.\n\n3.  **Layer Morph:**\n    -   When the `shortcuts_layer` is active, the first key triggers the `\u0026lm_copy` behavior.\n        -   If the `linux_layer` is **not** active (i.e., we are in MacOS mode), it sends `LG(C)` (Command-C).\n        -   If the `linux_layer` is active, it sends `LC(C)` (Control-C).\n    -   The second key triggers the `\u0026lm_paste` behavior, which works similarly for pasting (`LG(V)` or `LC(V)`).\n\n## Corne-ish Zen Example\n\nYou can see a variation of the example above implemented for my Corne-ish Zen [here](https://github.com/rafaelromao/zmk-config-zen-2/pull/1/files).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelromao%2Fzmk-layer-morph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaelromao%2Fzmk-layer-morph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelromao%2Fzmk-layer-morph/lists"}