GetButton
If you have a button defined as an axis in the Input Manager, you can use GetButton(), GetButtonDown(), and GetButtonUp() to determine when a button has been pressed.
GetButton() returns true while the button is being held, GetButtonDown() returns true only once, on the frame that the button is initially pressed, and GetButtonUp() returns true only once, on the frame that the button is released.
Within each of the functions, you place the axis name from the Input Manager within the parentheses within quotes. These functions should be checked in the Update() function of a script so that they are continuously being checked for.
So, for example, if you wanted to check whether the Enter key is being pressed since it is assigned to a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access