Sorry for the lack of comments, but here’s what I came up with.
The StackedKeyCodesAsInt generates a valid int that is unique for every keycode combination imaginable, the modifier of 429 is the highest number in the KeyCode enum.
The IntAsExpandedKeyCodes is the backwards conversion, the other functions are wrappers to replace the Input functions. And there’s that.
public static class KeyCodeManager
{
public static bool GetKeys( int keycodestack )
{
foreach (KeyCode key in IntAsExpandedKeyCodes( keycodestack ))
if (Input.GetKey( key ))
return true;
return false;
}
public static bool GetKeysDown( int keycodestack )
{
foreach (KeyCode key in IntAsExpandedKeyCodes( keycodestack ))
if (Input.GetKeyDown( key ))
return true;
return false;
}
public static bool GetKeysUp( int keycodestack )
{
foreach (KeyCode key in IntAsExpandedKeyCodes( keycodestack ))
if (Input.GetKeyUp( key ))
return true;
return false;
}
public static int StackedKeyCodesAsInt( KeyCode[] keycodes )
{
int output = 0;
int modifier = 1;
foreach (KeyCode keycode in keycodes)
{
output += modifier * (int)keycode;
modifier *= 429;
}
return output;
}
public static KeyCode[] IntAsExpandedKeyCodes( int keycodestack )
{
List<KeyCode> output = new List<KeyCode>() { (KeyCode)(keycodestack % 429) };
while (keycodestack > 429)
{
keycodestack /= 429;
output.Add( (KeyCode)(keycodestack % 429) );
}
return output.ToArray();
}
}
With Unity’s built in Input Manager you can assign a key and an alternate key for each action known as ‘axes’ which can be called using a string name. You can also add your own custom actions to the input manager.