There should be a scripting section for whatever game you're trying to make this for, but I'm sure it could just be done by switching bools/variables on and off whenever the right alt key is pressed, and have if else statements in your primary mouse button function.