Actually, if you use Karabiner Elements anyway, there's an easier way to achieve this:
Though it's quite a mixture of "worlds" (Karabiner/shell/GUI) its charm is that you do not need any other app(s) to get it "shortcut" ;-)
{ "parameters": {
"basic.to_delayed_action_delay_milliseconds": 1000},
"from": {
"key_code": "return_or_enter",
"modifiers": {
"mandatory": ["control", "shift" ] }
},
"to": [{"shell_command": "open -g /System/Library/¬
PreferencePanes/Keyboard.prefPane/"
}],
"to_delayed_action": {
"to_if_invoked": [ ___
{"key_code": "tab"}, | These key-codes
{"key_code": "tab"}, | can be replaced
{"key_code": "tab"}, | by a single osa-
{"key_code": "tab"}, | script, more ele-
{"key_code": "tab"}, | gantly, listed
{"key_code": "spacebar"}, | below ! *)
{"key_code": "q", |
"modifiers": ["command"]}, ___| < (Easier to handle)
{"key_code": "escape"}] },
"type": "basic"
}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
(* 'tell application \"System Events\" to tell process ¬
\"System Preferences\"\n click checkbox 1 of tab group 1 ¬
of window 1\n end tell\n quit application \"System Preferences\"'
As you can see, System Preferences Keyboard is opened by a shell-command, which demands "waiting time" for following key-codes (milliseconds: 1000).
I didn't find a keys-shortcut to get at the checkbox, so it navigates by 5 "tabs", one "spacebar" (= click), closes the prefpane and sets a final "escape" (without it my system reacts with a delay).
(I appended an extra, actually part of 1st answer's AppleScript, but adapted:\n
for line breaks, \"
for special keys.)
I installed a "Ctrl-Shift-Enter" shortcut, you may use s.th. else …
("caps_lock" at EventViewer sends either key_down or key_up – press twice to change states!)
This code can be inserted into your karabiner.json manually, or imported as a "complex modification" needs a "title: > rules: > description: > manipulators:" -framework (recycle existing one).