Event.command

Unity · Версия 2020.3 LTS · Scripting · Event

Event.command

public bool command;

Описание

Нажата ли клавиша Command/Windows? (Только чтение)

В Windows эта функция возвращает значение true, если удерживается любая клавиша Windows.
На Mac это возвращает true, если удерживается любая клавиша Command.

using UnityEngine;

public class Example : MonoBehaviour
{
    // Prints Command/Windows key was pressed depending the
    // platform this script is being run.
    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!");
            }
        }
    }
}

Обновлено 17 ноября 2026 г.