Destroy objects when key is pressed

Hi, I’m trying to grab/destroy an object when I pressed the “P” key for 1.5 seconds
I have this code, it would work if I don’t ask for “P”, just collide, but the game I’m working on ask for user interactions, any idea of what is wrong?

bool haveAPart = false;
string partName;
int curParts = 0;
float holdCounter = 1.5f;

void OnTriggerEnter(Collider co) {
		if ((co.tag == "CarPart") && (haveAPart == false)) { // User can only grab one part at a time
			partName = "Hold 'P' to grab " +; // show label with instructions to get the part
			if (Input.GetKeyDown (KeyCode.P)) {
				holdCounter -= Time.deltaTime; 
				if (holdCounter <= 0) { // user pressed the "p" key for 1.5 seconds
					haveAPart = true;
					Destroy (co.gameObject);
					partName = "You got: " +;
					holdCounter = 1.05f; // restart timer

Thanks! :slight_smile:

This code is expecting P to become pressed down during the exact same Update() frame when the collision happens. Extremely hard to make happen.

Study the difference

Input.GetKeyDown ()