Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseReturns true during the frame the user releases the key identified by name
.
You need to call this function from the Update function, since the state gets reset each frame.
It will not return true until the user has pressed the key and released it again.
For the list of key identifiers see Input Manager.
When dealing with input it is recommended to use Input.GetAxis and Input.GetButton instead
since it allows end-users to configure the keys.
function Update () { if (Input.GetKeyUp ("space")) print ("space key was released"); }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetKeyUp("space")) print("space key was released"); } }
Returns true during the frame the user releases the key identified by the key
KeyCode enum parameter.
function Update () { if (Input.GetKeyUp (KeyCode.Space)) print ("space key was released"); }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetKeyUp(KeyCode.Space)) print("space key was released"); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information