macOS keybinding, Karabiner-Elements
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:
- Distinguish left Ctrl vs right Ctrl, remap Esc, remap Enter key.
- Set Space bar to be Ctrl or ⌘ command when held down with another key, but as space itself when no other keys is pressed at the same time.
- Set keys to be device dependent. i.e. You have 2 keyboard. You want F2 to do different things.


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.

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" } ] }