相关文章推荐
好帅的扁豆  ·  Unity 性能规范·  1 月前    · 
暗恋学妹的红金鱼  ·  Android ...·  1 年前    · 
打酱油的菠萝  ·  Python之——pip is ...·  3 年前    · 
安静的自行车  ·  Windows ...·  3 年前    · 

Success!

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.

Close

Submission failed

For 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.

Close Cancel

Description

Returns true during the frame the user starts pressing down the key identified by name .

Call this function from the Update function, since the state gets reset each frame. It will not return true until the user has released the key and pressed it again.

For the list of key identifiers see Conventional Game Input . When dealing with input it is recommended to use Input.GetAxis and Input.GetButton instead since it allows end-users to configure the keys.

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour void Update () if ( Input.GetKeyDown ("space")) print("space key was pressed"); Is something described here not working as you expect it to? It might be a Known Issue . Please check with the Issue Tracker at Tutorials Community Answers Knowledge Base Forums Asset Store Terms of use Legal Privacy Policy Cookies Do Not Sell or Share My Personal Information