Your sample appeared to be slightly different than other rules I've looked at. Here's a version that works for me:
file: map_lctl_plus_open_bracket_to_close_bracket.json :
{
"title": "Map Lft-Ctl+Open-Bracket to Close-Bracket",
"rules": [
{
"manipulators": [
{
"description": "bracket rule",
"type": "basic",
"from": {
"key_code": "open_bracket",
"modifiers": {
"mandatory": [
"left_control"
],
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "close_bracket"
}
]
}
]
}
]
}
I wasn't able to determine any way to install the script other than through the "Import more rules from the internet"
option, but I did figure out how to launch the importer on my own files.
Assuming you copy the file into /tmp/map_lctl_plus_open_bracket_to_close_bracket.json
, pasting the following url into Safari should launch the importer:
karabiner://karabiner/assets/complex_modifications/import?url=file%3A%2F%2F%2Ftmp%2Fmap_lctl_plus_open_bracket_to_close_bracket.json
I have fully tested both the file content and the import url within this post, and all worked fine for me.
Good luck !
EDIT: Immediately after making this post, I think I found where the local filestore is for manually adding rules.
https://github.com/pqrs-org/KE-complex_modifications#local-testing
This is the github repo for the rules on the "Import more rules from the internet"
page. It shows how to test the rules locally before submitting to the web repository.
TL;DR:
$ cp my_rule.json ~/.config/karabiner/assets/complex_modifications
The site also confirms the karabiner://...
technique I mentioned above.
You'd have to manually edit ~/.config/karabiner/karabiner.json with e.g. BBEdit or TextEdit (better make a backup copy before you start!).
Be aware: your re-mapping would de-activate Apple's Spaces-switching feature!
Anyway, doing so you'd have to go to
"rules": [
and (assuming you mean the right control key) add s.th. like:
"rules": [
{ "description": "Call it whatever you like…",
"manipulators": [ {
"type": "basic",
"from": {
"key_code": "left_arrow",
"modifiers": {
"mandatory": [
"right_control"
]
}
},
"to": [
{
"key_code": "home"
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_arrow",
"modifiers": {
"mandatory": [
"right_control"
]
}
},
"to": [
{
"key_code": "end"
}
]
}
]
}
]
Be aware that the right order and correct corresponding of open and closed brackets of both types is essential!
(As far as I can see there is no way to debug this behaviour; maybe apart from watching Karabiner-Element's open Window while saving the json-file. Your choice of editor can help though, even BBEdit can identify pairs of brackets …)
If what you did is correct, the new behaviour will work instantaneously once you saved the file!
So, if yours is the only Complex Modification, the closing "comma" must NOT be used here … but if you add yours to all previous ones this "comma" must instead be placed in front of your code (meaning: behind the last rule's finishing bracket.
… a bit tricky, this all.
Best Answer
EDIT: I just added two "[ ]" brackets to the final "to":[{ -part, as their lack got s.o.an [error] !
==========================================================================
So, here is a "final version" (some notes to/from a first attempt are appended at bottom):
... some sample code that excludes any typing except letters "a" & "b".
This example is set to only work in TextEdit (for testing purposes) but of course you can change/delete this "conditions" (in last manipulator).
– The "Excluding" is prepared by
Shft-Ctrl-A
which solely sets"none_but_ab"
to true (1).– Next in line is a Stop-manipulator (security first); it sets
"none_but_ab"
to "0" after holding "x" 2 sec.– Both following parts out-put our "a" and "b" letters, excluding them from following annihilation.
– The fatal last manipulator grabs "any: key_code" and renders it to "none" …
– Be careful with your Stop-mechanism: singular keys work best, modified combos may fail!
– Some more ideas:
By adding "command" ("shift") to the last "from", you could prevent app-Cmd-shortcuts (capital letters).
Karabiner El. can start before login (Preferences > 'Copy the current …'); "password" would be affected!
I also would like to know how "Shift" could be applied to "any":"key_code", forcing capital letters, or if numbers can somehow be "selected". Well, let's see …
(Here are some remains from a first (deleted) answer at this:
note the twisted "any: key_code" part that calls every key, including "modifiers…any"
Interestingly 'from-to' units within
{manipulators: …}Karabiner.jsonare worked through from top to bottom
until one is executable.So if you want particular letters (a, b) to work nonetheless, you must call them previously.
Starting value for any variable is "0"
… values will "live" while Karabiner is running!… while experimenting I made my monitor sleep, but when I typed my pw – one letter simply was not recognised. I had to start from an external drive and change my code.
)