Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug & help] Additional keypress after pressing conditional command keys does not overwrite the command immediately #4016

Open
lightbluepoppy opened this issue Nov 16, 2024 · 1 comment

Comments

@lightbluepoppy
Copy link

Hi. I have been trying to use my keyboard as a mouse. I managed to use CapsLock + WASD to move the cursor. I also tried to implement slower cursor movement while pressing an additional Spacebar. However, pressing spacebar does not immediately change the cursor speed. After I press other WASD keys, I can see the spacebar is being enabled or disabled. How can I make this additional keypress immediately change the cursor speed?

Untitled.mov
karabiner.json
          {
            "description": "Caps Lock WASD Cursor",
            "manipulators": [
              {
                "from": {
                  "key_code": "caps_lock",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "set_variable": {
                      "name": "caps_lock pressed",
                      "value": 1
                    }
                  }
                ],
                "to_after_key_up": [
                  {
                    "set_variable": {
                      "name": "caps_lock pressed",
                      "value": 0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": { "key_code": "spacebar" },
                "to": [
                  {
                    "set_variable": {
                      "name": "spacebar pressed",
                      "value": 1
                    }
                  }
                ],
                "to_after_key_up": [
                  {
                    "set_variable": {
                      "name": "spacebar pressed",
                      "value": 0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_unless",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "a",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "x": -5000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_unless",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "s",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "y": 5000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_unless",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "w",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "modifiers": [],
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "y": -5000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_unless",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "d",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "x": 5000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "q",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [{ "pointing_button": "button1" }],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "e",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [{ "pointing_button": "button2" }],
                "type": "basic"
              }
            ]
          },
          {
            "description": "Caps Lock Spacebar WASD Cursor",
            "manipulators": [
              {
                "from": {
                  "key_code": "caps_lock",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "set_variable": {
                      "name": "caps_lock pressed",
                      "value": 1
                    }
                  }
                ],
                "to_after_key_up": [
                  {
                    "set_variable": {
                      "name": "caps_lock pressed",
                      "value": 0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": { "key_code": "spacebar" },
                "to": [
                  {
                    "set_variable": {
                      "name": "spacebar pressed",
                      "value": 1
                    }
                  }
                ],
                "to_after_key_up": [
                  {
                    "set_variable": {
                      "name": "spacebar pressed",
                      "value": 0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "a",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "x": -1000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "s",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "y": 1000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "w",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "modifiers": [],
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "y": -1000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  },
                  {
                    "name": "spacebar pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "d",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [
                  {
                    "mouse_key": {
                      "speed_multiplier": 1.0,
                      "x": 1000.0
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "q",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [{ "pointing_button": "button1" }],
                "type": "basic"
              },
              {
                "conditions": [
                  {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                  }
                ],
                "from": {
                  "key_code": "e",
                  "modifiers": { "optional": ["any"] }
                },
                "to": [{ "pointing_button": "button2" }],
                "type": "basic"
              }
            ]
          }
@tekezo
Copy link
Member

tekezo commented Nov 21, 2024

The spacebar rule should be as follows.

{
    "conditions": [
        {
            "name": "caps_lock pressed",
            "type": "variable_if",
            "value": 1
        }
    ],
    "from": { "key_code": "spacebar" },
    "to": [
        {
            "set_variable": {
                "key_up_value": 0,
                "name": "spacebar pressed",
                "value": 1
            }
        },
        { "mouse_key": { "speed_multiplier": 0.5 } }
    ],
    "type": "basic"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants