Processing keyboard button input like in GUI

Hello,

I have a simple UI where when you press a button on keyboard ‘Enter’ or gamepad on one menu, another submenu appears.
The problem is when I press the button, the new submenu appears and immediately process the input as if ‘Enter’ was pressed again.

if(Input.GetKey(KeyCode.JoystickButton0)) {
			activeButton.SendMessage("PressButton", SendMessageOptions.DontRequireReceiver);
}

I need to find a way where when the new menu appear, I have to leave the button and press again to go into the new submenu entry.

Any help is greatly appreciated, thanks for advance.

The problem you describe is due to the Input.GetKey() method you use, did you try to use Input.GetKeyDown or Input.GetKeyUp instead ?

It is said that Input.GetKey as the effect of an “auto fire” (see Unity’s documentation)