0
Answered

Get input keycode?

Sandberg 2 years ago updated 2 years ago 4

I'm creating a cheat system like Doom or Contra where the player enters an input combination in order. I used GetInputString but this doesn't print output for special keys like the arrows keys or return. Is there a node for getting a keycode similar to the GetInputString? I can already use a keycodes list as the variable for this system.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Answered

Unity doesn't have a built-in method or property for this apparently. You'd have to check for Input.GetKey and use the special characters yourself.

I can create a list of key code enums to check, but I can't check for each key code on input. Is there a unit for this?

If you have a list of key code enums, you can use the For Each Loop unit to check each of them inside the body. As soon as one of them returns true, you can execute your code (or set a temporary variable indicating it returned true) then use Break Loop to exit the loop.

The problem is that every key/button get input unit only outputs a boolean value. I haven't found one that returns an enum key value similar to getinputstring.

This is the system I've designed as it stands now. The list originally used strings for checking chars.