How to save Keyboard Input in a variable?

Im trying to clean up my Playercontroller and thought i could do a switch/case with the Input of which or if any Button is pressed at this frame instead of all these if/else in one function.

im trying to implement sth like that:

WhateverType KeyboardInput = null;

switch(getKeyboardInput())
{
case Keycode.W: PlayerMovement(V3Up; break;
case Keycode.S: PlayerMovement(V3Down); break;
...
case null: break;
}

But i just don’t know how can i get the Keyboard Input stored in a varibale :frowning:

may you know :slight_smile:

thx in advice

CKM

void Update(){
string keyboardInputString = Input.inputString;
switch (keyboardInputString){
case “k”:
// your logic here, for example // Application.Quit();
break;
}
}
I did not test this code, but it should work :smiley: