script for Jump help

I have the follwing part of a character controller code. The problem is that I have to press the jump button the hole time to perform a full jump. How i can make it, so when i press Space one time,it makes the whole jump?

if(Input.GetKey(KeyCode.Space))
{
	transform.position += transform.up * +jumpspeed * Time.deltaTime;
	Cam.transform.position += transform.up * +jumpspeed * Time.deltaTime;
		
}

take this command from the unity reference

with time.time, it makes the action repeat only if time + time duration has elapsed and button still pressed.

change the above code abit so that it jumps between the time you press jump and a time elapsed period after.

… make to variables, one = time when button was pressed and two = time when it was pressed + 2 seconds…

and say… if time.time is between time one and time two, jump

You can do this:

var jumpDelay : boolean;
var doubleJump : int = 0;
    function Update()
       {
            if( Input.GetKeyDown(KeyCode.Space) && jumpDelay == false)
       {
      		Jump();                    
    }
}

    function Jump()
       {
       		if (doubleJump <= 1)
       {
        	rigidbody.velocity.y = 175;
            	jumpTimer();
    }
}

    function jumpTimer()
       {
         if (Input.GetKeyDown(KeyCode.Space))
       {
         		doubleJump ++;
         }
         
         		if (doubleJump > 1)
         			{
         				doubleJump = 0;
         					jumpDelay = true;
       						yield WaitForSeconds(3);
         						jumpDelay = false;
    		}
		}

Make sure you have a rigid body attached to your character when you do this. I will write you a jump timer now so that the player cannot jump repeatedly, unless that’s what you want?

i should make it:
if(Input.GetKeyDown(KeyCode.Space))

instead of
if(Input.GetKey(KeyCode.SPace))