Begginer Jumping javascrpit problem.

I am making my first game in unity and do not have a lot of coding experience with java script. The game i can making is a simple ball rolling platformer. If i spam the jump button (w) my ball jumps the first time then when it lands it does not jump right away but it jumps randomly after a number of button presses. Here is the code.

pragma strict

var rotationSpeed = 100;
var jumpHeight = 8;
 
private var isFalling = false;
 
function Update ()
{
    //Handle ball rotation.
    var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    rotation *= Time.deltaTime;
    rigidbody.AddRelativeTorque (Vector3.back * rotation);
   
    if (Input.GetKeyDown(KeyCode.W) && isFalling == false)
    {
        rigidbody.velocity.y = jumpHeight;
    }
    isFalling = true;
}
 
function OnCollisionStay ()
{
    isFalling = false;
}

Set velocity to 0 when ball lands

rigidbody.velocity = Vector3.zero;
rigidbody.angularVelocity = Vector3.zero;