MCPcopy Index your code
hub / github.com/evan-liu/karabiner.ts

github.com/evan-liu/karabiner.ts @1.38.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.38.0 ↗ · + Follow
242 symbols 781 edges 71 files 41 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

karabiner.ts

License Coverage Status Wallaby.js npm deno module

Write Karabiner-Elements configuration in TypeScript.

[!NOTE] Use of TypeScript is optional. Config can also be written in JavaScript. Only the basics of JavaScript are needed. Check out my interactive course at codojo.dev.

Why karabiner.ts

karabiner.ts is heavily inspired by Goku. Compared to the edn format, it allows for:

  • Easier-to-understand TypeScript/JavaScript syntax
  • Strong-typed abstractions and key aliases with IDE support
  • Structured config files instead of one big file

And more features (abstractions) (hyperLayer, duoLayer, leaderMode, ...).

Learn More

Using the Online Editor

  1. Write config in the online editor.
  2. Copy the generated JSON then add to Karabiner-Elements.

[!NOTE] Importing JSON to Karabiner-Elements is only needed when using the Online Editor. karabiner.ts writes to ~/.config/karabiner/karabiner.json if using with Node.js or Deno.

Karabiner-Elements watches ~/.config/karabiner/karabiner.json and reloads it if updated.

Using Node.js

npm

Option 1

npx create-karabiner-config@latest

The default directory name is karabiner-config. You can pass another project-name:

npx create-karabiner-config@latest [project-name]

Then:

  1. Write your key mapping in src/index.ts.
  2. Set the profile name. Create a new Karabiner-Elements profile if needed.
  3. Run npm run build.

To update to the latest version, run npm run update (or npm update karabiner.ts).

Option 2

  1. Download (or clone | fork) the examples/starter repo.
  2. Run npm install.

Then write and build the config same as Option 1.

Option 3

npm install karabiner.ts

(or install with yarn, pnpm, etc) then call writeToProfile() from any Node.js script in your preferred way.

Using Deno

deno module

In a Deno script file (replace {version}):

import { writeToProfile } from 'https://deno.land/x/karabinerts@{version}/deno.ts'

writeToProfile('Default', [
  // rule(...
])

Then run it with:

deno run --allow-env --allow-read --allow-write {filename}

Extension points exported contracts — how you extend this code

RuleBuilder (Interface)
(no doc) [9 implementers]
src/config/rule.ts
WriteTarget (Interface)
(no doc)
src/output.ts
ManipulatorBuilder (Interface)
(no doc) [10 implementers]
src/config/manipulator.ts

Core symbols most depended-on inside this repo

build
called by 244
src/config/rule.ts
to
called by 106
src/config/manipulator.ts
map
called by 105
src/config/from.ts
manipulators
called by 72
src/config/rule.ts
toKey
called by 50
src/config/to.ts
layer
called by 48
src/config/layer.ts
ifVar
called by 46
src/config/condition.ts
toSetVar
called by 44
src/config/to.ts

Shape

Function 126
Method 91
Class 22
Interface 3

Languages

TypeScript100%

Modules by API surface

src/config/manipulator.ts44 symbols
src/config/to.ts25 symbols
docs/src/editor/online-editor.tsx22 symbols
src/config/layer.ts18 symbols
src/config/condition.ts17 symbols
src/config/rule.ts12 symbols
src/config/duo-layer.ts12 symbols
src/output.ts10 symbols
src/config/simlayer.ts10 symbols
src/config/modifier.ts9 symbols
src/config/mouse-motion-to-scroll.ts7 symbols
src/config/double-tap.ts7 symbols

For agents

$ claude mcp add karabiner.ts \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page