Use when configuring Karabiner-Elements keyboard customizations, before writing JSON - provides systematic workflow for complex modifications with correct structure, common patterns, and guidance on...
Karabiner-Elements is a macOS keyboard customization tool using JSON configuration. This skill provides a systematic workflow to create complex modifications correctly and efficiently.
Core principle: Clarify requirements first, choose simplest approach, use correct structure, test with EventViewer.
Use this skill when:
~/.config/karabiner/karabiner.jsonESPECIALLY under time pressure - templates prevent structural errors that waste more time debugging.
Don't use for:
If you catch yourself thinking:
All of these mean: Use the templates below. Faster AND correct.
ALWAYS ask if ambiguous:
digraph choose_approach {
"User comfortable with code?" [shape=diamond];
"Many complex rules?" [shape=diamond];
"Use external generator" [shape=box];
"Manual JSON" [shape=box];
"User comfortable with code?" -> "Many complex rules?" [label="yes"];
"User comfortable with code?" -> "Manual JSON" [label="no"];
"Many complex rules?" -> "Use external generator" [label="yes"];
"Many complex rules?" -> "Manual JSON" [label="no"];
}
External generators (more efficient for complex cases):
See: https://karabiner-elements.pqrs.org/docs/json/external-json-generators/
Manual JSON (direct editing):
Use templates below for common patterns.
Use Karabiner-EventViewer (included with Karabiner-Elements):
Don't rely on "it should work" - always test.
{
"description": "Change caps_lock to escape",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock"
},
"to": [
{
"key_code": "escape"
}
]
}
]
}
{
"description": "Change control+m to return",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "m",
"modifiers": {
"mandatory": ["control"]
}
},
"to": [
{
"key_code": "return_or_enter"
}
]
}
]
}
{
"description": "Caps lock to control (hold) or escape (tap)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"key_code": "left_control"
}
],
"to_if_alone": [
{
"key_code": "escape"
}
]
}
]
}
{
"description": "Command+h to delete in Terminal only",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "h",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"key_code": "delete_or_backspace"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": ["^com\\.apple\\.Terminal$"]
}
]
}
]
}
Config file: ~/.config/karabiner/karabiner.json
Structure: Add rules to the complex_modifications.rules array:
{
"profiles": [
{
"name": "Default profile",
"complex_modifications": {
"rules": [
// ADD NEW RULES HERE
{
"description": "...",
"manipulators": [...]
}
]
}
}
]
}
| Mistake | Fix |
|---|---|
Using "title" field |
Use "description" instead |
Extra "rules" wrapper |
Rule object has description + manipulators directly |
Forgetting "type": "basic" |
Always include in each manipulator |
| Wrong bundle identifier | Check app's bundle ID: osascript -e 'id of app "AppName"' |
| Not testing | Always use EventViewer to verify |
| Over-engineering | Start with simple approach, add complexity only if needed |
| Skipping skill under time pressure | Time pressure causes errors; templates save time |
| Excuse | Reality |
|---|---|
| "I'll work from memory to save time" | Memory fails under pressure. Templates take 10 seconds. |
| "I know the Karabiner syntax" | Knowing ≠remembering correctly. "title" vs "description" errors are common. |
| "This is too urgent for workflow" | Debugging wrong structure wastes 10x more time than using template. |
| "Simple config doesn't need templates" | Simple configs break from same field name errors as complex ones. |
| "Templates are slower" | Copy-paste template: 10 sec. Debug JSON error: 5 min. |
Common key codes:
"a" to "z""1" to "9", "0""left_control", "left_shift", "left_command", "left_option""escape", "return_or_enter", "delete_or_backspace", "tab", "spacebar""up_arrow", "down_arrow", "left_arrow", "right_arrow""f1" to "f12", "f13" to "f24"Full reference: Use EventViewer to see key codes for any key.
Avoid unless necessary. Simple modifier remapping works for 95% of cases.
Only use lazy modifiers when you specifically need the modifier itself not to generate events until combined with another key.
Following this workflow: