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"

Keyboard input in userwidget


I have been trying to add keyboard input to one of my userwidgets without any succes. There seems to be nothing about it online either so my question is how do I have one input doing different things depending on which userwidget I am in?

Thanks for your help

Product Version: Not Selected
more ▼

asked Jan 29 '15 at 09:20 PM in Blueprint Scripting

avatar image

Dennis Von Hedberg
11 4 8 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

4 answers: sort voted first

Hi! I've managed to find a way to capture keys in the widget blueprint. Take a look here. I don't know if this can help you. In my case I look if the Player Controller has pressed "M" key and then I remove the widget. but since this is inside a widget blueprint, you can do whatever you want ;)

alt text

more ▼

answered Feb 01 '15 at 08:29 PM

avatar image

191 5 11 141

avatar image Dennis Von Hedberg Feb 01 '15 at 08:36 PM

I found that way too, but do you know if it have any support from the key you setup inside of your action maping and axis maping. And does this way override the function from the same key inside of your player character?

avatar image xDatSimon Mar 11 '16 at 05:14 PM

Thank you so much! It working, I've been searching for 2 days after this! :)

avatar image Anes08 Dec 18 '17 at 05:24 PM


avatar image Peaches Martin May 20 '19 at 07:34 AM

Hi i would like to ask about this, i would like to use this method via pause menu. i already have my escape key for pause menu, but it seems that when i try to use this under the widget that needs to be closed, the event tick is functioning itself the way that i didnt intend to. what i mean is, it supposed to work when i want to close the pause menu using the escape key

avatar image Peaches Martin May 20 '19 at 07:36 AM

alt text

test.png (258.7 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi Dennis Von Hedberg,

The keyboard input can be set in your player controller. When you activate the key have it check which widget is currently set to viewport, and start the functions that you have set up in the widget. That should give you the control you are looking for from keyboard to UMG.

more ▼

answered Jan 30 '15 at 06:33 PM

avatar image Dennis Von Hedberg Jan 31 '15 at 03:09 PM

I am not sure how i should do that and if you understood what i meant. I want this line of functions inside of my userwidget.

ue4 userwidget.png (48.8 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users


I know this is an old post, but in case anyone else needs help getting a widget to register key presses I've found two ways:

1 - Using "Listen for Input Action", whenever you press a key associated with that action mapping it will trigger the "callback" event.

You have to "Set Input Mode Game And UI" for this to work.

"Consume" makes sure that this widget takes priority on what listens to that key press, e.g. so that when you press "jump" it isn't calling jump events on your character and in your widget, just the widget.

With this method you can change the keys associated with an action mapping and that change will be reflected in all widgets that you use this method with.

If an action mapping isn't specifically being "listened" to in the widget, your pawn will still receive that input.

This method doesn't seem to work if the game is paused, because the pawn will then receive no input.

alt text

2 - Overriding the "OnKeyDown" function to trigger a custom event that will do different actions based on what key was pressed.

I set the input mode to UI only.

Make sure to go to the widget options under "interaction" and set "is Focusable" to true.

With this method you can do it while the game is paused and the pawn won't be receiving inputs.

If you want to add another key to trigger an event you will have to manually add this change to all your widgets that you use this method with (I haven't figured out a way of avoiding that).

alt textalt text

more ▼

answered Aug 30 '18 at 12:15 AM

avatar image

Daniel Manthe
1 1 1

avatar image Jimminy_Cricket Oct 17 '18 at 01:05 AM

Hi Leone. I just wanted to say thanks as this issue was giving me a bad headache. I used your first solution and it has solved my problem completely. So glad I found this post. I'm almost done with my game and I couldn't believe this little thing was causing me more of a headache than everything else in the game mainly because my game consists of mainly widgets and only 2 blueprints.. Thanks again!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Another way to do that, in a paused game (Easy Way) is to simulate a paused game using Set Time Dilatation = 0. Doing that the system still get the character inputs but the game is "paused".

This works very well for me.

alt text

help01.png (254.0 kB)
more ▼

answered Apr 03 '19 at 03:02 AM

avatar image

1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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