I'm looking for a Linux replacement for a small AutoHotkey script I used while gaming on Windows. When I hold Left Alt and click the left or right mouse button, that button should remain pressed until I click the same mouse button again. I'm running CachyOS on Arch Linux and would prefer a straightforward solution, possibly using a shell script or a lightweight extra tool. The original scripts were:
LALT & LButton::Send % "{Click " . ( GetKeyState("LButton") ? "Up}" : "Down}" )
LALT & RButton::Send % "{Click right " . ( GetKeyState("RButton") ? "Up}" : "Down}" )
2 Answers
Input Remapper can handle fairly involved macros, including keyboard and mouse actions together. Its macro syntax supports holding keys, sending button events, waiting briefly, and running actions in parallel, which should cover most of this use case. Exact replication may take some trial and error, since a simple key remap and a stateful mouse-button toggle are different kinds of mappings.
Input Remapper is probably the easiest place to start. It supports macros involving both keyboard and mouse inputs, so you should be able to map Left Alt plus each mouse button and send the corresponding button-down or button-up event. On Arch-based systems, look for the input-remapper package or its binary AUR variant. You’ll likely need to experiment with conditional logic and held-button actions to reproduce the toggle behavior exactly.

Related Questions
Ray Trace Simulator – Interactive Optical Ray Tracing Tool
Wordsearch Generator
Random Maze Generator and Solver
Interactive Wheel Spinner Tool – Add Choices and Randomly Pick a Winner
Raffle Ticket Generator
Instant Online Dice Roller