Modifying left/right mouse click/hold to have an additional keypress

Example:

Input:
Click and hold left mouse button

Output:
Click and hold left mouse button
Click and hold [designated key]

How can I do this?

Also, how can I have the additional key effects cancel each other out when both left and right moouse buttons are clicked and held?

so, here, input:

Left mouse button clicked & held
Right mouse button clicked & held

Output:

Left mouse button clicked & held
Right mouse button clicked & held

[no addditional key press]

1 Like

Hi and welcome to the forum! :wave:t3:

Could you try to reframe your question with a real world application?

The way it's currently phrased isn't particularly clear.

"Click and hold" what?

The output appears to be the same as the input.

Hi, thank you for the prompt reply. Looks like I inadvertently used some kind of invisible text formatting thing by bracketing it between greater/lesser signs. I have edited now to:

Input:
Click and hold left mouse button

Output:
Click and hold left mouse button
Click and hold [designated key]

Regarding this part:

The output appears to be the same as the input.

Yes, here the goal is for those mouse buttons, when simultaneously pressed, to behave as they normally do, without the [designated key]s assigned to individual left or right mouse clicks.

The use case is for a game where movement and the camera are controlled by the mouse and keyboard. In the game, holding right click locks the camera to the third person character, and causes steered movement when combined with WASD-type keypresses. Holding left and right mouse buttons down together moves the character forward. I am attempting to get rid of the "WASD" movement and move solely with the mouse, so the mouse needs to let me move forward (left+right click & hold) or strafe while steering (left or right click and hold), by making the left key click also virtually press the left strafe key and the right click also virtually press the right strafe key, except when both are pressed.

You can't simulate holding a hardware key while actually holding one, as real hardware interaction will always interrupt simulated keys.

(Technically you can, using AppleScript, but it's never going to be snappy enough for use in a game.)

What you can do is repeat a key press between a mouse button being pressed and released, by using variables. This may or may not be good enough.

Place these macros in an app-specific group for your game. I've included a toggle macro that disables the mouse-click detection, in case you run into issues where you need to actually click something normally without it triggering keypresses. To toggle, hit ⌃⌥⌘L.

Click to Keystroke.kmmacros (73.5 KB)

If this isn't any good, you might want to investigate SteerMouse, which can remap your mouse in various ways. I don't use it, so I can't confirm whether it will suit this specific need, but it's worth a look.

Thank you

@noisneil almost always finds a solution. When others give up, he just gets started. :slightly_smiling_face:

Do I understand that correctly. You can't, for example, hold down the physical ⌃ key and press ⇧ virtually, too? If so, BTT can do that. However, it's not very reliable ... to be honest, it's not reliable at all. :joy: