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
asked Jan 29 '15 at 09:20 PM in Blueprint Scripting
Dennis Von Hedberg
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 ;)
answered Feb 01 '15 at 08:29 PM
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.
answered Jan 30 '15 at 06:33 PM
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.
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).
answered Aug 30 '18 at 12:15 AM
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.
answered Apr 03 '19 at 03:02 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here