Karabiner Mac Key mapping tool Notes
depth
2
Karabiner is the key mapping tool in mac.
The key mapping script syntax has changed. The "rules" top level element is gone. The "manipulators" and "description" appear at the top.
By default mouse buttons are not intercepted by karabiner (unlike keyboard), you need to enable it.
CapsLock key handling is special. It is better to leave caps key alone without mapping.
You need a hyper key without any delay handling. It will immediately generate Shift+Cmd+Ctrl+Opt combination.
You need another Cmd Mode Key (with large timeout like 1 or few secs) that will make the entire keyboard available for generating further keys.
Recommended Hyper Key configuration for me:
Chrome shortcuts:
hammerspoon shortcuts:
Alt + Space ==> Hyper-Key
Hyper2 + . ==> Show local windows for current application
Hyper + u ==> Minimize Window (mapped to Cmd M)
Hyper + o ==> Restore last minimized Window
Multiple keys mapped to left mouse click:
Hyper + i Hyper + ;
Hyper + d ==> Scroll up
Hyper + s ==> Scroll down
Global Karabiner Mappings:
Hyper + hjkl ==> Arrow keys Hyper + nm,. ==> Mouse Move Left, Down, Up, right Hyper + / ==> Left click
Raycast shortcuts:
System Shortcuts:
Raycast Hyper shortcut commands:
.
. Rule1: input --> manipulator1 --> manipulator2 --> ...
. |
. +--> Match Found, To key generated -> Rule1 Halt.
.
. Rule2: Rule1 Output --> Rule2 Manipulators.
.
. To Halt Processing: "to": [ { "key_code": "b" }, { "halt": true } ]
.
Parameter Examples: aaaaaaaaaaaaaaaa
{
"description": "Pressing the a,s,d keys simultaneously launches Mission Control",
"manipulators": [
{
"type": "basic",
"from": {
"simultaneous": [
{ "key_code": "a" },
{ "key_code": "s" },
{ "key_code": "d" }
],
"modifiers": { "optional": ["any"] }
},
"to": [{ "apple_vendor_keyboard_key_code": "mission_control" }]
}
]
}
{
"title": "Map Button 4 to F Key",
"rules": [
{
"description": "Map Button 4 to F Key",
"manipulators": [
{
"type": "basic",
"from": {
"pointing_button": "button4"
},
"to": [
{
"key_code": "f"
"modifiers": ["left_control"]
}
]
}
]
}
]
}
{
"title": "Toggle Command Mode with F1",
"rules": [
{
"description": "Toggle Command Mode with F1",
"manipulators": [
{
// When command_mode is 0, pressing F1 activates command mode
"type": "basic",
"from": {
"key_code": "f1"
},
"to_if_alone": [
{
// Set command_mode to 1
"set_variable": {
"name": "command_mode",
"value": 1
}
},
{
// Show notification for activation
"shell_command": "/usr/bin/osascript -e 'display notification \"Command Mode Activated\" with title \"Karabiner\"'"
}
],
// Condition checks if command_mode is currently 0
"conditions": [
{
// Only execute if command_mode is 0
"type": "variable_if",
"name": "command_mode",
"value": 0
}
]
},
{
// When command_mode is 1, pressing F1 deactivates command mode
"type": "basic",
"from": {
"key_code": "f1"
},
// Action when pressed alone while in command mode
"to_if_alone": [
{
// Set command_mode to 0
"set_variable": {
"name": "command_mode",
"value": 0
}
},
{
// Show notification for deactivation
"shell_command": "/usr/bin/osascript -e 'display notification \"Command Mode Deactivated\" with title \"Karabiner\"'"
}
],
// Condition checks if command_mode is currently 1
// This block should be executed when command_mode is active (1)
"conditions": [
{
// Only execute if command_mode is 1
"type": "variable_if",
"name": "command_mode",
"value": 1
}
]
}
]
}
]
}
...
{
"from": {
"pointing_button": "button4",
"modifiers": {
"mandatory": [ "left_shift"],
"optional": ["any"]
}
},
"to": [
{
"pointing_button": "button5"
}
],
"type": "basic",
"conditions": [
{
"bundle_identifiers": [
"^com.google.Chrome$"
],
"type": "frontmost_application_if"
}
]
}
Parameters for basic.to_delayed_action:
{
"type": "basic.to_delayed_action",
"from": {
"key_code": "application",
"modifiers": ["left_shift"]
},
"to_if_invoked": [
{ "key_code": "f16" }
],
"to_if_canceled": [
{ "key_code": "f17" }
],
"parameters": {
"basic.to_delayed_action_delay_milliseconds": 500
}
}
{
"description": "Use Application key as a chord to trigger F16–F20 with 200ms delay",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "application"
},
"to": [
{
"set_variable": {
"name": "application_key_active",
"value": 1
}
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"set_variable": {
"name": "application_key_active",
"value": 0
}
}
],
"to_if_canceled": [],
"delay_milliseconds": 200
}
},
{
"type": "basic",
"conditions": [
{
"type": "variable_if",
"name": "application_key_active",
"value": 1
}
],
"from": {
"key_code": "q"
},
"to": [
{
"key_code": "f16"
}
]
},
{
"type": "basic",
"conditions": [
{
"type": "variable_if",
"name": "application_key_active",
"value": 1
}
],
"from": {
"key_code": "w"
},
"to": [
{
"key_code": "f17"
}
]
},
{
"type": "basic",
"conditions": [
{
"type": "variable_if",
"name": "application_key_active",
"value": 1
}
],
"from": {
"key_code": "e"
},
"to": [
{
"key_code": "f18"
}
]
},
{
"type": "basic",
"conditions": [
{
"type": "variable_if",
"name": "application_key_active",
"value": 1
}
],
"from": {
"key_code": "r"
},
"to": [
{
"key_code": "f19"
}
]
},
{
"type": "basic",
"conditions": [
{
"type": "variable_if",
"name": "application_key_active",
"value": 1
}
],
"from": {
"key_code": "t"
},
"to": [
{
"key_code": "f20"
}
]
}
]
}