Problem with input

So I’m making a 2D controller script, and I’ve come up with a problem…

if(controller.velocity.y == 0)
	{
		speedY = 0;
	}
	
	if(Physics.Raycast(transform.position, -Vector3.up, .5f))
	{
		if(isJumping)
			isJumping = false;
		if(isAirborne)
			isAirborne = false;
		if(Input.GetKey("space"))
		{
			isJumping = true;
			speedY = jumpHeight;
		}
	}
	else
	{
		isAirborne = true;
	}
	if(controller.velocity.x == 0)
	{
		speedX = 0;
	}

Not really sure if there’s something wrong with the input, or that part of the code is just messed up… the rest seems to work fine?

Thanks for any help at all

The best ways of handling input are either to add the input into the InputManager and call to the specified input or to directly call to the keycode of the key you are trying to press.

Here’s some examples:

Input from input manager;

//requires an input labeled "Jump" in the InputManager
if(Input.GetButtonDown("Jump")){
     Debug.Log("Jump");
}

//calls to the exact key that you want to press
if(Input.GetButtonDown(KeyCode.Space)){
     Debug.Log("Jump")
}