x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to show Input Key in Text / String

I want to show "Press E to interact" as a text, but instead of the "E" I want to display the actual mapped button for that specific input. How do I create a text or string like that?

Product Version: Not Selected
Tags:
more ▼

asked Mar 17 '15 at 10:13 AM in Blueprint Scripting

avatar image

Blue669
236 28 34 54

avatar image Blue669 Jun 06 '15 at 11:05 AM

bump Is there no way to get what key an input is assigned to? Not exposed to Blueprint?

avatar image Narghile Jun 06 '15 at 12:55 PM

Hi

Are you allowing players to map there own Keys?

Narg

avatar image Blue669 Jun 06 '15 at 01:00 PM

Sure, that's the point of assigning input keys, isn't it?

avatar image Narghile Jun 06 '15 at 01:09 PM

Ok,

Sorry mate but you question was just how to display it.

So you have already worked out how to Set up the Key Maping so it works, so this should be sort of simple then.

Can you show how you have set this up so we can have a look and give some suggestions.

Narg

avatar image Blue669 Jun 06 '15 at 01:13 PM

Currently I'm just using a string that says "Hold E to pick up item". What I want to do is somehow take the correct key of that input and then build a string around it. Something like "Hold" {inputkey} "to pick up item"

avatar image Narghile Jun 06 '15 at 01:15 PM

Ok, have you played with appending stuff?

Narg

avatar image Narghile Jun 06 '15 at 01:34 PM

This will make a String from any variables.

alt text

Narg

capture.jpg (32.3 kB)
avatar image Narghile Jun 06 '15 at 01:36 PM

It goes on and on my friend.

alt text

Narg

capture.jpg (53.5 kB)
avatar image Blue669 Jun 06 '15 at 01:41 PM

Yes, I know. Now tell me how you define that variable so it is the input key that is assigned to it.

avatar image Narghile Jun 06 '15 at 01:45 PM

You are having this for when for you go near a BP such as, Pickup Item, Open Door, Talk to shopkeep?

Narg

avatar image Blue669 Jun 06 '15 at 01:47 PM

Yes, text shows up when near an interactable object.

avatar image KWS Jun 06 '15 at 02:10 PM

OP is not asking how to append strings.

Rather how to store "typed" text in a variable.

avatar image frezer748 May 04 '18 at 07:02 PM

Are there any updates on this?

(comments are locked)
10|2000 characters needed characters left

5 answers: sort voted first

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.

more ▼

answered May 04 '18 at 07:53 PM

avatar image

Blue669
236 28 34 54

avatar image frezer748 May 04 '18 at 08:12 PM

That's awesome! Thank you very much, you've probably saved me a lot of time figuring this out! :-)

(comments are locked)
10|2000 characters needed characters left

EDIT: Thought I should make this a bit clearer.

There's an override function called OnKeyDown in UMG Blueprint.

1) Create a Widget Blueprint.

alt text

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.

alt text

3) Select "OnKeyDown"

alt text

4) There's a bunch of things you can do but here's a quick example to print the keypress to screen.

alt text

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.

alt text

6) I added a button as something to click on to make sure the UI has focus.

alt text

7) When playing, hit Shift+F1 to release the mouse, click the button for focus and type away!

alt text

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+)

more ▼

answered Jun 06 '15 at 03:01 PM

avatar image

KWS
125 5 7 15

avatar image KWS Jul 02 '15 at 11:33 PM

Editing an answer might not trigger a re-notification email, so I'm bumping with this comment in hopes that it prevents the Asker from missing the updated info above. :)

avatar image Blue669 Jul 03 '15 at 06:08 AM

This is interesting, but not an answer to my initial question. Maybe this is useful if you want to rebind keys, but it seems this is not supported in Blueprint right now.

The Rama Plugin doesn't work for some reason, it crashes my application.

avatar image gagallo7 Jan 28 '17 at 09:10 PM

I needed to create this key consumer widget without any component in canvas. To do that, you need to:

Figure 1) Set Widget's inherited variable bIsFocusable to true.

Figure 2) Call SetKeyboardFocus on the widget from PlayerController, or anything that may deal with input.

alt text alt text

(comments are locked)
10|2000 characters needed characters left

I think this is a good place for a feature request. We need the following nodes:

Retrieve the assigned action/axis mapping keys.

Reassign action/axis mappings at runtime.

more ▼

answered Jul 24 '15 at 10:39 PM

avatar image

Hitpawz
541 22 26 43

(comments are locked)
10|2000 characters needed characters left

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.

Narg

more ▼

answered Jun 06 '15 at 01:55 PM

avatar image

Narghile
1.7k 73 38 107

avatar image Blue669 Jun 06 '15 at 02:06 PM

It seems that setting different keys for input is also not supported in Blueprint...

(comments are locked)
10|2000 characters needed characters left

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. alt text

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: alt text

more ▼

answered Aug 21 '18 at 08:31 PM

avatar image

WhippyTrout
1 1

avatar image Blue669 Aug 21 '18 at 08:41 PM

Not sure if your method would actually work since the "key" is part of your event. I've answered my own question (since it's been years when I first posted this) just above your post. Maybe my answer can give you satisfying results as well.

avatar image WhippyTrout Aug 21 '18 at 11:30 PM

Yea I just started getting into UE4 so I didn't think about it. Your right. My way won't initially give any value. It just gives you "NONE" on your Strings until you press the "Use" key you assigned. :( Oh well.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question