Keyboard Events not Working after Interacting with Widget

Hi all,

In my project, when the player presses a certain key, it opens the inventory by calling an event on my widget blueprint. It then does Set Input Mode Game and UI and passes the widget reference into the In Widget To Focus pin. It also sets Show Mouse Cursor to true. If I then interact with my widget and press the key to close my inventory, nothing happens. I have to click outside my widget then press it for it to work. Is there a way I can make the game still respond to keyboard events whilst using a widget?

Thanks in advance!

Override onKeyDown in the widget and close it here (make the widget responsible for closing itself) or pass unhandled during onKeyDown which should pass the priority back to the controller.

Hi,

Sorry for the late reply. I tried both these things but it appears OnKeyDown isn’t getting called at all. Could this be anything to do with the fact that all the widgets in my HUD are the children of a retainer box with an effect material?

Could this be anything to do with the
fact that all the widgets in my HUD
are the children of a retainer box
with an effect material?

Unlikely, this shouldn’t affect the widget’s ability to handle input. To clarify, if you put a Print String node right after onKeyDown - it does not fire? Are you sure the widget is in focus? Is the isFocusable flag set to True for the widget root?

I made the IsFocusable flag set to true, and now when I first open my inventory and press a key down the event fires properly. But if I interact with my widget (eg. click a button) and then press a key it doesn’t fire.

Try making everything else in the widget not focusable so it does not steal keyboard focus. The default settings for this are weird.

Thanks! This works. I made all the buttons on my widget not focusable and it fixed everything.