Command for Holding a Key Down & Shift Key

#Question 1: Command for Key Holding
What is the command for creating an action while a key is being HELD as opposed to PRESSED. I want Shift to make my character run:

var speed : float = 6.0;

var runSpeed : float = 20;

moveDirection = Vector3(Input.GetAxis(“Horizontal”), 0,

Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;

if (Input.GetButtonDown (“Shift”)) {

moveDirection *= runSpeed;

}

else {

moveDirection *= speed;
}

So, I can’t get the “runSpeed” to stay active because it isn’t happening upon the button being HELD as opposed to PRESSED (I think).

#Question 2: Command for Shift Input

what is the GetButtonDown (“Shift”)) command for Shift, because I tried “Shift” and that wasn’t working either.

thanks!

You detect shift, alt, and control in OnGUI, so I set 3 boolean vars, which I set accordingly in OnGUI off the Event.current.shift (for example). Then you can use those booleans in your Update function to see if those keys are held when another key is hit. You can also track the ‘last state’ of those booleans and compare them to see if shift, control, alt were pressed or released.

Now would be a good time to see if they fixed all the bugs: Mac Keys not showing up, or very strangely... - Questions & Answers - Unity Discussions

if (Input.GetButtonDown(“Shift”)) {
running = true;
}
else if (Input.GetButtonUp(“Shift”)) {
running = false;
}

moveDirection *= running? runSpeed : speed;

When using GetButton, you set the keys in the input manager. You’d need both right shift and left shift, so you can use those for the positive button and alt positive button.