How to show Input Key in Text / String
Yes. In fact, since 4.17 this is a supported feature in the Unreal Engine.
To access any action key name, add the following nodes:
"Get Input Settings" > "Get Action Mapping by Name" > enter the name of the action you want > "Break Action Key Mapping Struct" > from the KEY > Get Display Name
For axis mappings, just replace action with axis and do the same steps.
If player has multiple key bindings for the same action, you can add them one after another and place an "or" between the keys or just take the first you get. You can also filter out Gamepad buttons and display them seperately if you add a branch with a "is gamepad key" from the key in the struct.
EDIT: Thought I should make this a bit clearer.
There's an override function called OnKeyDown in UMG Blueprint.
1) Create a Widget Blueprint.
2) Open it and switch to the Graph view, and in the Functions section of the My Blueprint Panel, Click to open the Override dropdown.
3) Select "OnKeyDown"
4) There's a bunch of things you can do but here's a quick example to print the keypress to screen.
5) Add the following in the Level Blueprint, CharacterBP or somewhere to add the Widget to the viewport. Select the name of your Widget in the Class selector of the Create Widget node.
6) I added a button as something to click on to make sure the UI has focus.
7) When playing, hit Shift+F1 to release the mouse, click the button for focus and type away!
But if that doesn't work out for you, take a look at Rama's UMG Rebindable Key System, It's free and appears to do everything you need! (Original Project is for 4.5, but a vid was posted later in the thread showing how to use in 4.7+)
Could you store some of that data in the BP it self, and activate on overlap.
So when the character chooses what their bindings are, you set a Var for each in an array or just as. This is now "E" Var.
When the BP get spawned, and gets the "Key" Stoke VAR it needs, such as "Q".
On begin overlap, you can access that VAR and input that in to your string.
answered Jun 06 '15 at 01:55 PM
I had the same issue and wanted to display the key players had selected inside my strings. So If you go to your Project Settings -> Input. You can Edit your keys for your game. In my case I wanted to have a "Use" key and wanted that key to appear every time i wanted to Use something such as a door or to pickup an item.
So once you set your Inputs go back to whatever blueprint your wanting the string on and get the Node for your Input. In my case it's "Use" So I type "Use" and "Input Action Use" appears. Next drag a wire off of the "Key" pin and type get "Key Display Name" then you can use that in your strings. I use my HUD class to display Text on my players HUD for hints. So mine looks like this:
answered Aug 21 '18 at 08:31 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here