Karabiner-elements: New modifier style with set_variable does not consider other modifiers(?)

Created on 24 Aug 2017  路  3Comments  路  Source: pqrs-org/Karabiner-Elements

For example, I map caps_lock+J to left_arrow.
caps_lock sets a var=1, and var is a condition for J.

Now I've tried for three hours to make
shift+caps_lock+J => shift+left_arrow
, but it seems there is no way.
I could do explicit mappings for all modifier combos (caps+J, shift+caps+J, shift+control+caps+J etc etc), but that would be a huge config.

It works when I map caps_lock to fn - but if I understand correctly, this is old school.

If it helps you read it, here is part of my config.
Can I somehow apply the optional modifiers of caps_lock (shift, control, alt) to the resulting to: keycode of 'J' ?

                    "manipulators": [
                        {
                            "from": {
                                "key_code": "caps_lock"
                            },
                            "to": [
                                {
                                    "set_variable": {
                                        "name": "cl_down",
                                        "value": 1
                                    }
                                }
                            ],
                            "to_after_key_up": [
                                {
                                    "set_variable": {
                                        "name": "cl_down",
                                        "value": 0
                                    }
                                }
                            ],
                            "type": "basic"
                        },
                        {
                            "conditions": [
                                {
                                    "name": "cl_down",
                                    "type": "variable_if",
                                    "value": 1
                                }
                            ],
                            "description": "cursor left",
                            "from": {
                                "key_code": "j"
                            },
                            "to": [
                                {
                                    "key_code": "left_arrow"
                                }
                            ],
                            "type": "basic"
                        }

Most helpful comment

Just for the record: this is how you map

CapsLock + J (+ any modifier) to
CursorLeft (+any modifier that is currently pressed) :

                    "manipulators": [
                        {
                            "from": {
                                "key_code": "caps_lock",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            "to": [
                                {
                                    "set_variable": {
                                        "name": "cl_down",
                                        "value": 1
                                    }
                                }
                            ],
                            "to_after_key_up": [
                                {
                                    "set_variable": {
                                        "name": "cl_down",
                                        "value": 0
                                    }
                                }
                            ],
                            "type": "basic"
                        },


                        {
                            "conditions": [
                                {
                                    "name": "cl_down",
                                    "type": "variable_if",
                                    "value": 1
                                }
                            ],
                            "description": "CURSOR_LEFT",
                            "from": {
                                "key_code": "j",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            "to": [
                                {
                                    "key_code": "left_arrow"
                                }
                            ],
                            "type": "basic"
                        }

All 3 comments

Try this:

```"manipulators": [
{
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"left_shift","right_shift"
]
}
},
"to": [
{
"set_variable": {
"name": "cl_down",
"value": 1
}
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "cl_down",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "cl_down",
"type": "variable_if",
"value": 1
}
],
"description": "cursor left",
"from": {
"key_code": "j",
"modifiers": {
"optional": [
"left_shift","right_shift"
]
}
},
"to": [
{
"key_code": "left_arrow"
}
],
"type": "basic"
}
]

Woohoo it works!! Thanks!
I was sure I've tried this variant before, but obviously not correctly.

Note: it also works with the 'any' modifier, which is exactly what I wanted.

YES! I have not used my MBA since Sierra came out, because my special layout is hardwired into my fingers. Editing JSON with broken cursor control was like... typing with your nose.
I'm 10x faster now that Karabiner is back.

And thank you Tekezo-San, you rock!

Just for the record: this is how you map

CapsLock + J (+ any modifier) to
CursorLeft (+any modifier that is currently pressed) :

                    "manipulators": [
                        {
                            "from": {
                                "key_code": "caps_lock",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            "to": [
                                {
                                    "set_variable": {
                                        "name": "cl_down",
                                        "value": 1
                                    }
                                }
                            ],
                            "to_after_key_up": [
                                {
                                    "set_variable": {
                                        "name": "cl_down",
                                        "value": 0
                                    }
                                }
                            ],
                            "type": "basic"
                        },


                        {
                            "conditions": [
                                {
                                    "name": "cl_down",
                                    "type": "variable_if",
                                    "value": 1
                                }
                            ],
                            "description": "CURSOR_LEFT",
                            "from": {
                                "key_code": "j",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            "to": [
                                {
                                    "key_code": "left_arrow"
                                }
                            ],
                            "type": "basic"
                        }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fengur picture Fengur  路  3Comments

KyleAtDND picture KyleAtDND  路  3Comments

DanweDE picture DanweDE  路  3Comments

rcaputo picture rcaputo  路  3Comments

LittleNewton picture LittleNewton  路  3Comments