On Key Down Not Triggering

Hi, I want to print my pressed key on the screen so I used this to do it:

But it doesn’t get triggered (my widget is added to the viewport).
Does anybody know what I did wrong?

1 Like

It didn’t do anything.
I followed this tutorial: How to Create A Terminal System in UE4
and this is my world blueprint:

And it’s based on the ThirdPersonBP.

Put a break point on your print string node. On windows, you can press F9

Now test your widget, and when you press a button, the game should pause and the editor should focus on your break point.

If nothing happens, then there is something wrong with the design part of your widget and we will need more info to help

well at some point you have to use SetInputModeUI if you want OnKeyDown to trigger.

If you don’t use this function, the game consumes all of your inputs

1 Like

In the widget enable Is Focusable then make sure visibility is set to visible. Then on begin play Set Focus function. Now your key down should trigger, but if you click any mouse key it will remove focus and you won’t get any key triggers. (You could have some code that runs Set Focus when you need to type.)

Or instead of Set Focus you could just override mouse down and that should automatically make the widget focused when you press any mouse key then you will be able to type any key and get key down trigger.

1 Like

It’s what I did here:

1 Like

How can I set Focus?

nvm I found it, thank you

Would you mind posting a screenshot of the whole process? Having the same issue and got kind of lost following this thread. Thanks!

Almost 1 hour trying and searching. What finally worked is the node Set Visibility.
I forgot that I changed it in the Designer mode. Something so simple can take so much time.

So what was the issue then and how did you solve it? Thanks

Thanks anonymous_user_dfedb823 !! I follow a tutorial on Youtube and the person talk about the “Focusable”, but not the set Visibility.
I select the root of the widget, type visibility in the search bar and set the it to “Visible” and it work now :+1:

Setting it to focusable was the missing piece for me. Needed to hit Class Defaults > Interaction > IsFocused

1 Like