How do I get a specific key binding for a specific action in blueprint? For example “get key binding for jump” and it would return spacebar or A depending on controller or keyboard.
In your project settings there is a setting called “inputs”.
You simply set those, give them a name and inside blueprint you then can search for that name in the context menu.
I hope this helps.
If you want to get/set action inputs via blueprints at runtime check this out:
Thanks! I’ll look into this.
PlayerInput isn’t accessible via blueprint. To do so, you should create a function in C++ for your Player Controller class.
##this method may only be applicable in 4.15
#If your end result is to look like this:
Where the text displays the key to use…
You only need two nodes to retrieve the key.
##To get the “text”:
- The ACTION EVENT node (Project Settings → Input)
- “Key Get Display Name”.
- You can now put the output of Key Get Display Name into strings or UMG texts~!
Please be aware that this will return the key undecorated (not surrounded with brackets).
##To decorate the text:
- Create an Append node, create three inputs.
- Put the output of Key Get Display Name into input 2.
- In input 1 and 3, put whatever decoration or pre/affix text you wish.
In my example, “[” is in input 1, and "] " is in input 3.
The problem with getting the key display name from the input action, however, is that you can’t know what the key is until the user has pressed it.
The “Key Get Display Name” node is useful, but you need to get that action’s mapping first. There are nodes for this.
Specifically, you can do “Get Input Settings”->“Get Action Mapping By Name” if you know the action you’re looking for.
That will give you an array of mappings that will have all the keys in it that you can get the display names from.
This works great! Thanks for the help.
I needed the same functionality - not possible to do it easily I don’t think (unless something has changed).
My workaround (no c++ required) was to ignore the built-in input events and instead drive my input via the “Any Key” event and a list of input mappings. It’s a lot more work than I probably make it sound, and you have to be careful to account for things the user might do, but if you want to try, this can get you started:
Create a map variable, and an enum of input names. Set up mappings in the map variable’s defaults:
When the “Any Key” event is fired, check the key and run appropriate actions depending on which key was pressed:
Like I said, this can open up a can of worms, but you gotta do what you gotta do… I needed an “input polling” type of input for my game anyway, so I kinda already had to do something along these lines.
Very useful! Thank you very much!
Yeah, I wrote the answer back in Uni, which was the first time I used the GUI stuff.
I’ll update it when I get the engine installed again~
In blueprint you can get your action key this way :
This is wrong, check out Manoloon’s answer.