So I have a skill system, and each skill has different key combination to press in order to trigger that skill.
For example, Dash() skill, I want to trigger it by press W key and LeftShift Key. Can I do things like below image. I loop through all keys to check all key got entered.
Explanation for this image: skillInterruptKeys are KeyCode[ ][ ], two dimensions array. Each time, I retrieve one KeyCode[ ] to Check if this combination is pressed all. And if there’s a key in this key combination not pressed, it would not show all keys pressed.
As so far, I have no test case, I wonder if this way is working from you guys’ experience.
From a quick look, it looks fine to me. Just so long as you expect all the keys to be held down at the same time. If you need keys to be pressed in order rather than all at the same time, then you’d need to design a different system.
Note that if you’re using the legacy input system and shift keys there is some weirdness to be aware of.
Also beware that every different model of keyboard has different characteristics about how many keys can be simultaneously chorded. Sometimes it will jam (drop keys) and other times it might ghost keys.
Here is a discussion:
Short answer based on experience: don’t rely on more than two keys at once being pressed.