So I'm writing a custom action that is meant to work like Get Key, but it reads from a keyCode variable instead of a predetermined key set by the developer. This action currently mostly works as intended, but strangely doesn't work for a keyboard key when a mouse button is also held down.
To clarify, if the keyCode variable's value IS a mouse button, it works. If the value is a keyboard key, it works IF AND ONLY IF a mouse button isn't also being pressed, and I want the action to work for keyboard keys regardless if a mouse button is pressed or not.
Here's the code so far. StoreResult always returns false if a mouse button is held and a keyboard key is being tested, and I'm not sure why.
void DoGetKey()
{
int kHit = 0;
if (key==KeyCode.None){ //key is referring to the original 'key' variable in the old GetKey Action
foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode))){
if (Input.GetKey(vKey)){
keyE = vKey;
kHit++;
if (key2.Value.ToString()==keyE.Value.ToString()){
storeResult.Value = true;
continue;
}else {
storeResult.Value = false;
}
}
}
}
else{
storeResult.Value = Input.GetKey(key);
kHit++;
} if (kHit == 0){
storeResult.Value = false;
}
}