Skip to content

Commit b898318

Browse files
committed
Try fix command key status in windows
1 parent 03f43d6 commit b898318

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Assets/Scripts/Event/InputEvent.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ public bool ctrlOrCmd
9494
{
9595
get
9696
{
97-
return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)
98-
|| Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand);
97+
return ctrl || command;
9998
}
10099
}
101100

@@ -104,7 +103,7 @@ public bool ctrlOrCmd
104103
/// </summary>
105104
public bool ctrl
106105
{
107-
get
106+
get
108107
{
109108
return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
110109
}
@@ -139,7 +138,11 @@ public bool command
139138
{
140139
get
141140
{
142-
return Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand);
141+
//In win, as long as the win key and other keys are pressed at the same time, the getKey will continue to return true. So it can only be shielded.
142+
if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)
143+
return Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand);
144+
else
145+
return false;
143146
}
144147
}
145148
}

0 commit comments

Comments
 (0)