Event.command 键盘Command/Windows键

var command : bool

Description描述

Is Command/Windows key held down? (Read Only)

Command/Windows键被按住了么(只读)?

On Windows, this returns true if any Windows key is held down.
On Mac, this returns true if any Command key is held down.

Windows系统,如果任意Windows键被按下,返回真;
Mac系统,如果任意Command键被按下,返回真。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnGUI() {
		Event e = Event.current;
		if (e.command)
			if (Application.platform == RuntimePlatform.OSXEditor)
				Debug.Log("Command key was pressed");
			else
				if (Application.platform == RuntimePlatform.WindowsEditor)
					Debug.Log("Windows Key was pressed!");


	}
}
// Prints Command/Windows key was pressed depending the
// platform this script is being run.
//打印Command或Windows键被按下,这个脚本,具体取决于正在运行的平台。

function OnGUI() {
	var e : Event = Event.current;
	if (e.command) {
		if(Application.platform == RuntimePlatform.OSXEditor) {
			Debug.Log("Command key was pressed");
		} else if( Application.platform == RuntimePlatform.WindowsEditor) {
			Debug.Log("Windows Key was pressed!");
		}
	}
}
Page last updated: 2010-12-31