DEV Community

Brisbane Web Developer
Brisbane Web Developer

Posted on • Edited on

3 3

CTRL key based operation with Karabiner-Elements

Summary

Adapting to the MacBook Pro's Command key-centric layout was challenging after years of using my ThinkPad X1 Extreme Gen 2. To avoid the transition, I started using Karabiner-Elements.

Karabiner-Elements lets you:

  • Remap keys to match your muscle memory
  • Create complex shortcuts
  • Customise per-app layouts

About Karabiner-Elements Rule

  • I use another Simple modification to replace Option to Command with the Rule in this post.

  • When you want to target a specific application to apply the keyboard manipulation, you need to figure out the value for bundle_identifiers called Bundle Identifier.

  • You can find Bundle Identifier on the terminal as follows (com.microsoft.VSCode is it in this example), but it is easier to figure out with EventViewer provided by Karabiner-Elements instead:

grep -A 2 "Identifier" /Applications/Visual\ Studio\ Code.app/Contents/Info.plist
======
<key>CFBundleIdentifier</key>
<string>com.microsoft.VSCode</string>
Enter fullscreen mode Exit fullscreen mode

The File

.history
.vscode
save.sh
view raw .gitignore hosted with ❤ by GitHub
{
"title": "Use Option as Command for some applications",
"rules": [
{
"description": "Use Option as Command for some applications",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"right_shift",
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "open_bracket",
"modifiers": [
"left_shift",
"left_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "close_bracket",
"modifiers": [
"left_shift",
"left_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "f",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "f",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_unless",
"bundle_identifiers": [
"^com.googlecode.iterm"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "x",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "x",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "p",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "n",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "n",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "q",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "q",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "z",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "z",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_unless",
"bundle_identifiers": [
"^com.googlecode.iterm"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "z",
"modifiers": {
"mandatory": [
"right_shift",
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "z",
"modifiers": [
"right_shift",
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "c",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "c",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_unless",
"bundle_identifiers": [
"^com.googlecode.iterm",
"^com.microsoft.VSCode"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "v",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "v",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "a",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "a",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_unless",
"bundle_identifiers": [
"^com.googlecode.iterm",
"^com.microsoft.VSCode"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "s",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "s",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "t",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "t",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.cocoatech.PathFinder-setapp",
"^com.microsoft.edgemac",
"^com.google.Chrome",
"^com.googlecode.iterm"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "l",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.edgemac",
"^com.google.Chrome"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "n",
"modifiers": {
"mandatory": [
"left_shift",
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "n",
"modifiers": [
"left_shift",
"left_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.edgemac",
"^com.google.Chrome"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "g",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "g",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.edgemac",
"^com.google.Chrome"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "u",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "u",
"modifiers": [
"left_option",
"left_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.edgemac",
"^com.google.Chrome"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "h",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "y",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.google.Chrome"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "y",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "y",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.edgemac"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "w",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "w",
"modifiers": [
"right_command"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "slash",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "slash",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.install4j.[-0-9]+.[-0-9]+$",
"^com.microsoft.VSCode"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "r",
"modifiers": {
"mandatory": [
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "r",
"modifiers": [
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.edgemac",
"^com.google.Chrome"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "period",
"modifiers": {
"mandatory": [
"control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "period",
"modifiers": [
"command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.VSCode"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"left_shift",
"left_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "p",
"modifiers": [
"left_shift",
"left_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.VSCode"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "y",
"modifiers": {
"mandatory": [
"right_shift",
"right_control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "y",
"modifiers": [
"right_shift",
"right_command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.VSCode"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "k",
"modifiers": {
"mandatory": [
"control"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "k",
"modifiers": [
"command"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.tinyspeck.slackmacgap"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "p",
"modifiers": {
"mandatory": [
"left_ctrl",
"left_shift"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "p",
"modifiers": [
"left_command",
"left_shift"
]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com.microsoft.VSCode"
]
}
]
}
]
}
]
}
view raw use-option.json hosted with ❤ by GitHub

References

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Retry later
👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay