Using Karabiner for multi key to multi key remapping
-
25-05-2021 - |
Question
I have been using Karabiner for some key remappings on a macbook pro. I have successfully (and very satisfyingly) remapped right-cmd + up arrow and right-cmd + down arrow to page up and page down.
I would like to do further remappings, such as remap shift + enter so that it will give me line breaks in messages, or cmd + anglebrackets to switch workspaces. Unfortunately the only way I know to do these things are with two key strokes in the first place (option + enter for messages new lines and control + arrow keys to switch workspaces). How can I use karabiner to make two key presses map to two other key presses?
Solution
Ok I solved my two specific problems, though I am still not sure how I would replicate multiple key presses if more than one of them were not modifier keys.
Put the following two json files in user/.config/karabiner/assets/complex_modifications
{
"title": "Shift + Enter",
"rules": [
{
"description": "Shift + Enter to Option Enter (newline in messenger)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "return_or_enter",
"modifiers": {
"mandatory": [
"shift"
],
"optional": [
"caps_lock",
"option"
]
}
},
"to": [
{
"key_code": "return_or_enter",
"modifiers": [
"option"
]
}
]
}
]
}
]
}
This one (shift enter) is really frustrating me but not because of karabiner. In messenger i need to option+enter to get a new line character, but in the browser option-enter refuses to do anything. I wish I could get a key combination that does a consistent "safe" new line character, rather than making me fear I am going to accidentally press enter to send or complete or publish or something like that.
{
"title": "cmd + angle brackets for workspaces",
"rules": [
{
"description": "Use CMD + comma (left angle bracket key) to switch to left workspace",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "comma",
"modifiers": {
"mandatory": [
"command"
],
"optional": [
"caps_lock",
"option",
"control"
]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": [
"control"
]
}
]
}
]
},
{
"description": "Use CMD + . (right angle bracket key) to switch to left workspace",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "period",
"modifiers": {
"mandatory": [
"command"
],
"optional": [
"caps_lock",
"option",
"control"
]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": [
"control"
]
}
]
}
]
}
]
}
A solution to a similar question can be found here: How to bind a key to press two separate keys