Can I simulate two seconds of 'getKeyDown' with a 'getKey' command?

Hi, I’d like to use getKeyDown(“space”) to behave as if it were getKey(“space”), and the player had held ‘space’ for exactly two seconds. Is this possible?

var requiredTime : float;
private var currentTime : float;

function Update() {
	if (Input.GetKey(KeyCode.Space)) {
		//key is held during this frame; increment and check timer
		currentTime += Time.deltaTime;
		if (currentTime >= requiredTime) {
			//key has been held down for at least 'requiredTime' seconds
		}
	} else {
		//key is not down; reset timer
		currentTime = 0;
	}
}

If you want your code to fire only once after those X seconds are up, you’ll have to set a control flag once the key is pressed, then clear that flag once it’s released.