in the code bellow it´s impossible to print "FBleftcontrol", also depending on the order and combination of keys pressed sometimes other lines are impossible to print
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
bool LeftControl = false;
bool LeftShift = false;
bool LeftAlt = false;
// Update is called once per frame
void Update()
{
LeftControl = Input.GetKey(KeyCode.LeftControl);
LeftShift = Input.GetKey(KeyCode.LeftShift);
LeftAlt = Input.GetKey(KeyCode.LeftAlt);
if (LeftAlt || LeftShift) fb();
else fa();
}
private void fb()
{
print("fb");
if (LeftControl)
{
if (Input.GetKeyDown(KeyCode.Alpha1)) print("leftcontrol");
}
else
{
if (Input.GetKeyDown(KeyCode.Alpha1)) print("NOleftcontrol");
}
}
private void fa()
{
print("fa");
if (LeftControl)
{
if (Input.GetKeyDown(KeyCode.Alpha1)) print("leftcontrol");
}
else if(LeftShift)
{
if (Input.GetKeyDown(KeyCode.Alpha1)) print("leftshift");
}
}
}
Things I´ve tried: latch booleans; use all posible combinations of getkey/getkeydown/getkeyup; put it all in the update and forget about calling functions