public void ProcessKeyEvent(InputAction.CallbackContext context)
{
string keyName = context.control.displayName;
// "Any Key" also gets triggered by this method, so I filter this out.
if (keyName == "Any Key") return;
if (context.control is KeyControl keyControl && Enum.TryParse(keyName, out Key key))
{
InputActionPhase phase = context.phase;
print(phase);
// The code does reach here because I can see the phases being printed
// in the logs, but as mentioned 'performed' seems to only be firing on
// release alongside 'canceled'.
if (phase == InputActionPhase.Performed)
{
HeldKeys.Add(key);
KeyDown?.Invoke(key);
}
else if (phase == InputActionPhase.Canceled)
{
HeldKeys.Remove(key);
KeyUp?.Invoke(key);
}
}
}