macOS keybinding, Karabiner-Elements

By Xah Lee. Date: . Last updated: .

Karabiner-Elements

Karabiner-Elements (was known as KeyRemap4MacBook in 2014) lets you do advanced key remapping.

Download at 〔Karabiner-Elements At https://karabiner-elements.pqrs.org/

Karabiner is very advanced. You can:

karabiner elements 2017-09 60028
karabiner elements 2017-09 60028
KeyRemap4MacBook 2014-01-29
KeyRemap4MacBook 2014-01-29

View Keypress and Keycode

It'll also install a “Karabiner-EventViewer”. It's in your Applications folder.

Launch it, and press key or mouse button and it'll show the keycode.

Karabiner eventViewer 2020-06-12
Karabiner eventViewer 2020-06-12

Sample JSON Key Config File

some advanced key mappings are done by using a file in JSON Data Format. You have to write the file.

there is no graphical user interface.

config is located at ~/.config/karabiner/karabiner.json

here's some sample config i use.

f11 f12 prev next tab

{
    "description": "f11 f12 prev next tab",
    "manipulators": [
        {
            "from": {
                "key_code": "f11"
            },
            "to": [
                {
                    "key_code": "tab",
                    "modifiers": ["left_shift", "left_control"]
                }
            ],
            "type": "basic"
        },
        {
            "from": {
                "key_code": "f12"
            },
            "to": [
                {
                    "key_code": "tab",
                    "modifiers": [ "left_control"]
                }

            ],
            "type": "basic"
        }
    ]
}

f10 close tab

{
    "description": "f10 close tab",
    "manipulators": [
        {
            "from": {
                "key_code": "f10"
            },
            "to": [
                {
                    "key_code": "w",
                    "modifiers": [ "left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}

shift f11 f12 for fine volume controls

{
    "description": "shift f11 f12 for fine volume controls",
    "manipulators": [
        {
            "from": {
                "key_code": "f11",
                "modifiers": { "mandatory": ["shift"] }
            },
            "to": [
                {
                    "key_code": "volume_decrement",
                    "modifiers": ["left_shift", "left_option"]
                }
            ],
            "type": "basic"
        },
        {
            "from": {
                "key_code": "f12",
                "modifiers": { "mandatory": ["shift"] }
            },
            "to": [
                {
                    "key_code": "volume_increment",
                    "modifiers": ["left_shift", "left_option"]
                }
            ],
            "type": "basic"
        }
    ]
}

f3 f4 copy paste

{
    "description": "f3 f4 copy paste",
    "manipulators": [
        {
            "from": { "key_code": "f3" },
            "to": [
                {
                    "key_code": "c",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        },
        {
            "from": { "key_code": "f4" },
            "to": [
                {
                    "key_code": "v",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}

f9 prev app

{
    "description": "f9 prev app",
    "manipulators": [
        {
            "from": { "key_code": "f9" },
            "to": [
                {
                    "key_code": "tab",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}