to.set_variable

set_variable defines and updates the variable value.

{
    "to": [
        {
            "set_variable": {
                "name": "variable name",
                "value": variable value,
                "key_up_value": variable value,
                "type": "set"
            }
        }
    ]
}
Name Required Description Available since
name Required Target variable name. Karabiner-Elements 11.0.0
value Required | Optional Target variable value. Karabiner-Elements 11.0.0
key_up_value Optional A variable value when key is up Karabiner-Elements 14.12.6
type Optional “set” or “unset” Karabiner-Elements 14.99.2

Note: If key_up_value or type is specified, the value can be omitted.

Available types of value

Type Example value Available since
integer 0,1,2,… Karabiner-Elements 11.0.0
boolean true, false Karabiner-Elements 14.4.20
string “layer1”, “layer2” Karabiner-Elements 14.4.20

Examples

{
    "set_variable": {
        "name": "mode_flag",
        "value": 1,
        "key_up_value": 0
    }
}
{
    "set_variable": {
        "name": "mode_enabled",
        "value": true
    }
}
{
    "set_variable": {
        "name": "layer_name",
        "value": "layer1"
    }
}
{
    "set_variable": {
        "name": "my_flag",
        "type": "unset"
    }
}

Confirm the current variable values

You can see the current variable values by EventViewer > Variables.

eventviewer-variables@2x.png