to_if_other_key_pressed

to_if_other_key_pressed changes a key while it is being held down if another specified key is pressed during that time. Its main use is to change modifiers under specific conditions, as in the example below.

Example

Change option+tab to command+tab.

{
    "description": "Change option+tab to command+tab",
    "manipulators": [
        // Change left_option to left_command if tab key is pressed together.
        {
            "type": "basic",
            "from": {
                "key_code": "left_option",
                "modifiers": { "optional": ["any"] }
            },
            "to": [{ "key_code": "left_option" }],
            "to_if_other_key_pressed": [
                {
                    "other_keys": [
                        {
                            "key_code": "tab",
                            "modifiers": { "optional": ["any"] }
                        }
                    ],
                    "to": [
                        {
                            "key_code": "left_command"
                        }
                    ]
                }
            ]
        },

        // Change right_option to right_command if tab key is pressed together.
        {
            "type": "basic",
            "from": {
                "key_code": "right_option",
                "modifiers": { "optional": ["any"] }
            },
            "to": [{ "key_code": "right_option" }],
            "to_if_other_key_pressed": [
                {
                    "other_keys": [
                        {
                            "key_code": "tab",
                            "modifiers": { "optional": ["any"] }
                        }
                    ],
                    "to": [
                        {
                            "key_code": "right_command"
                        }
                    ]
                }
            ]
        }
    ]
}