Skip to content

Instantly share code, notes, and snippets.

@toonetown
Last active March 14, 2024 16:42
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save toonetown/ec7d3e74807fcc57362dc34dd47a4570 to your computer and use it in GitHub Desktop.
Save toonetown/ec7d3e74807fcc57362dc34dd47a4570 to your computer and use it in GitHub Desktop.
Karabiner Elements JSON configuration for Microsoft Remote Desktop
{
"title": "Microsoft Remote Desktop",
"rules": [
{
"description": "Windows Mappings",
"manipulators": [
{
"type": "basic",
"from": { "key_code": "x", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "x", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "c", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "c", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "v", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "v", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "a", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "a", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "z", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "z", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "s", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "s", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "p", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "p", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "f", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "f", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "b", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "b", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "i", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "i", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "u", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "u", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "n", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "n", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "t", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "t", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "comma", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "comma", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "k", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "k", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "l", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "l", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "g", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "g", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "period", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "period", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "open_bracket", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "open_bracket", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "close_bracket", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "close_bracket", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "slash", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "slash", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "k", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "k", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "z", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "z", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "g", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "g", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "b", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "b", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "f", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "f", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "r", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "r", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "slash", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "slash", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "left_arrow", "modifiers": { "mandatory": [ "option" ] } },
"to": [ { "key_code": "left_arrow", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "right_arrow", "modifiers": { "mandatory": [ "option" ] } },
"to": [ { "key_code": "right_arrow", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "left_arrow", "modifiers": { "mandatory": [ "option", "shift" ] } },
"to": [ { "key_code": "left_arrow", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "right_arrow", "modifiers": { "mandatory": [ "option", "shift" ] } },
"to": [ { "key_code": "right_arrow", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "left_arrow", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "home", "modifiers": [ ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "right_arrow", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "end", "modifiers": [ ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "left_arrow", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "home", "modifiers": [ "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "right_arrow", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "end", "modifiers": [ "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "up_arrow", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "up_arrow", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "down_arrow", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "down_arrow", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "up_arrow", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "up_arrow", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "down_arrow", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "down_arrow", "modifiers": [ "left_control", "shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "q", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "f4", "modifiers": [ "fn", "left_option" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "w", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "f4", "modifiers": [ "fn", "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "r", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "f5", "modifiers": [ "fn" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "comma", "modifiers": { "mandatory": [ "command", "option" ] } },
"to": [ { "key_code": "comma", "modifiers": [ "left_command" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "c", "modifiers": { "mandatory": [ "command", "option" ] } },
"to": [ { "key_code": "c", "modifiers": [ "left_command" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "q", "modifiers": { "mandatory": [ "command", "option" ] } },
"to": [ { "key_code": "q", "modifiers": [ "left_command" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "h", "modifiers": { "mandatory": [ "command", "option" ] } },
"to": [ { "key_code": "h", "modifiers": [ "left_command" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "z", "modifiers": { "mandatory": [ "command", "option" ] } },
"to": [ { "key_code": "z", "modifiers": [ "left_command" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "w", "modifiers": { "mandatory": [ "command", "option" ] } },
"to": [ { "key_code": "w", "modifiers": [ "left_control", "left_option" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "d", "modifiers": { "mandatory": [ "command" ] } },
"to": [ { "key_code": "d", "modifiers": [ "left_control" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
},
{
"type": "basic",
"from": { "key_code": "d", "modifiers": { "mandatory": [ "command", "shift" ] } },
"to": [ { "key_code": "d", "modifiers": [ "left_control", "left_shift" ] } ],
"conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "com\\.microsoft\\.rdc\\.macos" ] } ]
}
]
}
]
}
@toonetown
Copy link
Author

toonetown commented Sep 6, 2017

This is a configuration that I use for Karabiner Elements to allow for mapping keyboard shortcuts. Since I generally use Parallels Desktop whenever I'm using Windows locally, I like to map the keys the same way. This set of mappings does that.

The documentation around this syntax is not very complete - most of this was calculated from looking through the examples that are included in the source as well as the extensions that are publicly available.

Note: you can access the JSON versions of these public examples by prepending https://pqrs.org/osx/karabiner/complex_modifications/json/ to the file name you are looking for - i.e. https://pqrs.org/osx/karabiner/complex_modifications/json/remote-desktop.json

To get an application's bundle_identifier, you can run the following command:

mdls -name kMDItemCFBundleIdentifier /Path/To/Application.app

To import a file into Karabiner Elements, I found the easiest was to run:

open "karabiner://karabiner/assets/complex_modifications/import?url=<PERCENT_ENCODED_URL>"

where <PERCENT_ENCODED_URL> is an HTTPS URL to the JSON file, which has been percent encoded.

For example, to load the latest version of this gist file directly into Karabiner Elements, you can run:

open "karabiner://karabiner/assets/complex_modifications/import?url=https%3A%2F%2Fgist.githubusercontent.com%2Ftoonetown%2Fec7d3e74807fcc57362dc34dd47a4570%2Fraw%2Fkarabiner-elements-remote-desktop.json"

Also - if you add a new set of complex modifications (such as this one), it will not replace a previous version with the same names. I find that when working on crafting these JSON files, it is easier to remove the previously-set and previously-imported complex modifications before loading new ones - so as not to be confused about which settings are which.

@ys-qb
Copy link

ys-qb commented Feb 12, 2019

I used the forked one since the bundle id is different to me. "com\.microsoft\.rdc\.macos" --> "com\.microsoft\.rdc\.mac"
Thanks!

open "karabiner://karabiner/assets/complex_modifications/import?url=https%3A%2F%2Fgist.githubusercontent.com%2Fgregflint%2F01f212ccb21cedb23b7fbb2ff1aa9e66%2Fraw%2F358d8e06859048a98f5965b52c17a16e41debf13%2Fkarabiner-elements-remote-desktop.json"

@DennyWeinberg
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment