Control widget with key press?


I’m sure this should be really simple, but I can’t figure out exactly how it’s done.

I have a UI I have built in a Widget Blueprint. I want to be able to make changes to it with key presses, for example pressing Space starts/stops something on the UI.

But in the Widget Blueprint itself, I can’t get a key press event. It seems one can only get those types of events inside a Player Controller Blueprint, or am I mistaken?

So I assume I need the key press to fire some kind of event in the Player Controller, which the Widget is listening for?

Would love some help to figure this out!


Hi localstarlight,

You need to use “Set Keyboard Focus” after “Add to Viewport”

Then go to your Widget Blueprint and override the function “On Key Down” or “On Key Up”, whatever you want.

By last, in the new function you can detect any key you want.

I really don’t know all the differences about return Handled or Unhandled, but I know that Handled block another Inputs that are in another blueprint, Unhandled not.

Thanks for your reply (ages ago!) – I still haven’t managed to make this work.

I’ve tried what you suggested (I think). Here is my Level Blueprint:

Screen Shot 2016-05-12 at 12.30.26.png

And here’s my Widget Blueprint:

Screen Shot 2016-05-12 at 12.30.48.png

When I press ‘A’ it doesn’t do anything – it doesn’t go down either fork of the branch, so it’s clearly not coming through.

What am I doing wrong?!

So I realised I hadn’t done what you’d suggested. For some reason the ‘Set Keyboard Focus’ node wasn’t showing up for me until I turned off ‘Context Sensitive’.

So now it looks like this:


But it still doesn’t do anything when I press the ‘A’ key…

Not 100% certain, but if that’s in the Level Blueprint, then you will probably need to tell who the Owning Player is when creating the widget.

I have tried adding that, so now Level Blueprint looks like this:


But still doesn’t work…

So, does it actually draw the widget to the screen, or is it just not accepting the override input?

The widget draws fine, just not accepting any input. Is there another step/setting needed to make this work?

I can’t believe this is such an unusual thing to want to do, and yet nothing I try seems to work.

Does anyone know of a tutorial that goes through such a thing? Or does anyone have a working example of affecting a widget with the keyboard that I could look at?

this works, however you will need to use event tick for all the widget that needs input, and you need to define it for each key.
i am in the same page as you trying to enable the input for the widget, even worst since i want to swipe my widget.

There’s one piece missing here that I needed to make this work. Maybe it’s new since this was posted. In the widget, after event construct, you need to set Is Focusable to true. This allows the Set Keyboard Focus node to work. Then the key down event overrides also work.

Make an input action for your key press.

From inside the Widget Blueprint:

Works for me, thanks guys. Unreal 4.23

Maybe I’m too late but the thing you need to do to make a widget get some input is to use SetInputModeUIOnly when you create your widget. So all the input events will be sent to the widget