Input.anyKeyDown 任意键按下?

static var anyKeyDown : bool

Description描述

Returns true the first frame the user hits any key or mouse button (Read Only).

在第一帧用户按下某一按键或鼠标按钮,返回true(只读)

You should be polling this variable from the Update function, since the state gets reset each frame. It will not return true until the user has released all keys / buttons and pressed any key / buttons again.

当这个状态在每一帧重新设定时,你可以在Update方法中轮流检测这个变量。它将不会返回true除非你松开(释放)所有的按键/按钮然后再按下某个按键/按钮。

using UnityEngine;

using System.Collections;



public class example : MonoBehaviour {

	void Update() {

		if (Input.anyKeyDown)

			Debug.Log("A key or mouse click has been detected");



	}

}
// Detects if any key has been pressed down.

//检测是否有按键被按下



function Update() {

	if(Input.anyKeyDown)

		Debug.Log("A key or mouse click has been detected");

}
Page last updated: 2011-3-30