Way to get all keys currently held down

Is there a way to get an array, a set, or some other type of collection that would return all the keys currently being held down? I am looking for ways to check for key combinations whithout having to call the GetButtonDown a whole bunch of times and using ifs (I am lazy). Does the inputString() method always return all the keys currently held down?

Just noticed I posted in the wrong forum. Sorry about that :sweat_smile:

inputString is only useful for keydown events. Think keyboard typing. You might hold down a key for a long time but it will be in the inputString only for one frame, unless you let the key go and press it again or the system wide key repeat rate kicks in.

Otherwise you have to use Input.GetKey and check every key. What exactly do you want to do?

Good question. Don’t really know :slight_smile: I was thinking of having a dictionary with the key combitnations as, well, keys, and have the corresponding methods or objects to call as the values. Sorta like:

methodNameToCall = routingDictionary,getValueFromDictionaryForKey(depressedKeys) ;
if (methodNameToCall is not null)
   myObject.methodNameToCall();

instead of a string of ifs

if (Input.GetKey('a')
   myOb ject.methodA();
if (Input.GetKey('a')  Input.GetKey('b'))
   myObject.methodAB();
if (Input.GetKeyy('c')  Input.GetKey('d')
   myObject.methodCD();
...

You could write a for loop going through each character instead of doing it manually for every one of them.

See www.ASCIITable.com