How to get a key binding in blueprint?

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.

Cheers

If you want to get/set action inputs via blueprints at runtime check this out:

[Full Project] Rama's UMG Rebindable Key System, Rebind keys at Runtime! - Programming & Scripting - Unreal Engine Forums!

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.

https://i.gyazo.com/65dad97330cfa79dacd010c5219c67f0.png

https://i.gyazo.com/726ec6694daeeeb063ff15e4cac26be5.png

https://i.gyazo.com/96bf4698c9412b5de9ad5afccff0fba5.png

##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…

#How do?
You only need two nodes to retrieve the key.

##To get the “text”:

  1. The ACTION EVENT node (Project Settings → Input)
  2. “Key Get Display Name”.
  3. You can now put the output of Key Get Display Name into strings or UMG texts~! :slight_smile:
    Please be aware that this will return the key undecorated (not surrounded with brackets).

##To decorate the text:

  1. Create an Append node, create three inputs.
  2. Put the output of Key Get Display Name into input 2.
  3. 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.
1 Like

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:

223826-keymap01x.png

223827-keymap01b.png

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. :stuck_out_tongue:
I’ll update it when I get the engine installed again~

In blueprint you can get your action key this way :

265759-2019-01-18-11-21-20-cooptps-unreal-editor.png

3 Likes

This is wrong, check out Manoloon’s answer.

I did it this way in my Widget’s text binding

3 Likes