In the Unity 5 editor, when I try to give input in Update with a control-key mod, the key-press of another key is not rightly registered.
If I have:
void Update()
{
if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) &&
Input.GetKey(KeyCode.X)) Debug.Log(true);
}
And my input is: Left-Ctrl + X, nothing is printed. Same with Right-Ctrl + X.
However, if I have Shift + Ctrl + X, then “true” is printed! By not specifying “right” or “left,” I mean to imply it does not matter which is the case.
And Alt + Ctrl + X also prints “true”
This is true for all the letters on a standard keyboard in-place of X, it would seem after testing a few.
However, if I have
void Update()
{
if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Alpha1))) Debug.Log(true);
}
By pressing a Ctrl-Key alone will solicit the output: “true”
I have no problem integrating the control-keys with mouse clicks nor shift or alt with other keys, so what is happening here that is messing with the input so?
Edit: I want to clarify that it works when I build the project, but as noted at the beginning this weird, and I hesitate to call it a bug, “bug” only exists in the editor. I’m trying to find a way around it.