releasing GetKey problem

i am currently trying to add to a mini golf tutorial i got earlier by adding a power variable to the shot. The problem i have is that i can’t get a boolean to be set to true when releasing the h key. Is there any way to get around this?

function powerGuage() {
var hitDirection:Vector3=Vector3(ball.transform.position.x - transform.position.x, 0.0f, ball.transform.position.z - transform.position.z).normalized;


	if(Input.GetKey("h")  shot ==false){
	shotPower += Time.deltaTime;
		
		if(Input.GetKeyUp("h")){
			print("key");
			keyReleased = true;
			print("keyReleased");
	
			if(shotPower >=3  keyReleased){
			shot=true;
			GUIScript.shotNumber++;
			print ("hit the ball");		
			ball.rigidbody.AddForce(hitDirection * hitForce, ForceMode.Impulse);
			}
			
			if(shotPower <=3  keyReleased){
				shot=true;
				GUIScript.shotNumber++;
				print ("hit the ball");
				//var hitDirection:Vector3=Vector3(ball.transform.position.x - transform.position.x, 0.0f, ball.transform.position.z - transform.position.z).normalized;
				ball.rigidbody.AddForce(hitDirection * (hitForce*shotPower), ForceMode.Impulse);
			}
		}
	}
}

You’re checking for GetKeyUp only when GetKey is true, so it will never be evaluated. As soon as the key is released, Input.GetKey(“h”) is no longer true and any code within that if statement won’t be evaluated.

You need to seperate the logic.

if(Input.GetKey("h")  shot ==false){
	shotPower += Time.deltaTime;
}

if(Input.GetKeyUp("h")){
			print("key");
			keyReleased = true;
			print("keyReleased");
	
			if(shotPower >=3  keyReleased){
			shot=true;
			GUIScript.shotNumber++;
			print ("hit the ball");		
			ball.rigidbody.AddForce(hitDirection * hitForce, ForceMode.Impulse);
			}
			
			if(shotPower <=3  keyReleased){
				shot=true;
				GUIScript.shotNumber++;
				print ("hit the ball");
				//var hitDirection:Vector3=Vector3(ball.transform.position.x - transform.position.x, 0.0f, ball.transform.position.z - transform.position.z).normalized;
				ball.rigidbody.AddForce(hitDirection * (hitForce*shotPower), ForceMode.Impulse);
			}
		}

chears for that. i hate when i just miss out one simple thing