Getting the name of a button pressed?

Hey everyone,

I’m kind of stuck with an annoying problem, and I can’t find a solution anywhere. I’ve got a load of if statements and I’d like to put them in switch statement instead. But I need to get the name of the button being pressed.
There doesn’t seem to be a way to access the Inputmanager eighter?

// buttonPressed = Input.GetKey(); //Put name of the button being pressed in a temporary variable.
// switch (buttonPressed){
case “Jump”:
//do stuff
break;
}here

Instead of:
if (Input.GetButton(“Jump”))
{
//Do stuff
}

Thanks many many!

removed

@gavinb80 that has nothing to do with keyboard input… op is asking for a “get current keyboard input” rather than doing “if this keyboard input… if that keyboard input… if the other keyboard input… if something else keyboard input…” etc.

Ah got confused by the use of the term “button being pressed” rather than key.

Apologies

Any particular reason why you’re fixated on using a switch statement? Switch statements are meant to evaluate the current state of a single thing, not multiple things in different states. What if the player presses two buttons at the same time? Are you just going to ignore one?

Thank for your answer. I only want players to be able to press one button at a time, so that’s why I wanted to use a switch!