Get the key value of an input action

Hi.

I want to create a system where it displays for example: [E] to interact with door
It differs depending on the item, which I’ve worked out using interfaces, but the E must adapt to whatever the player sets their input key as. How do I access the value of this input action and turn it into a string?

Thanks.

2 Likes

This is how you could get the key of a specific input action in a specific context:

3 Likes

Here’s another way:

22 Likes

Thanks!
This worked for me.

1 Like

It returns the key with the “0”, so if in Input Mapping Context you have first Input Action as mouse/keyboard and second as gamepad: just drag off from “key” → “is input key down” to make sure which was actully pressed.

It’s not so simple. E.g. In case you have multiple keys mapped to one action, but value is necessary. I’ve got case for change weapon, one input action, with few keys → 1, 2, 3, 4. And I need to know which slot was pressed, even so it’s still single action.