# Keyboard loses focus when opening HUD element

**URL:** <https://forums.unrealengine.com/t/keyboard-loses-focus-when-opening-hud-element/508852>\
**Category:** Blueprint\
**Tags:** unreal-engine, UI, UE4-26, question\
**Created:** [March 22, 2022, 10:45am UTC](https://forums.unrealengine.com/t/keyboard-loses-focus-when-opening-hud-element/508852 "2022-03-22T10:45:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GernalIeal](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gernalieal/32/1182908_2.png) [@GernalIeal](https://forums.unrealengine.com/u/GernalIeal)\
**Post date:** [March 22, 2022, 10:45am UTC](https://forums.unrealengine.com/t/keyboard-loses-focus-when-opening-hud-element/508852/1 "2022-03-22T10:45:40Z")

</div>

When I open my inventory HUD with TAB, i can’t close it. The only way to close the HUD is to first click on the screen and then press TAB

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/b/74be69735011f99494b6ab34ee309bc137775ccf.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 22, 2022, 11:21am UTC](https://forums.unrealengine.com/t/keyboard-loses-focus-when-opening-hud-element/508852/2 "2022-03-22T11:21:14Z")

</div>

How is the `Tab` key pressing implemented in the the widget’s `onKeyDown`? Is the widget keyboard focusable?

Here’s the whole shebang:

> [@Close menu with same button as opening](https://forums.unrealengine.com/t/close-menu-with-same-button-as-opening/485710/10):
>
> Not stupid at all, actually. It’s just an input processing thing. Set Input Mode UI Only prevents the Player Controller from processing input - pressing M while this mode is active does nothing, the PC ignores it, as instructed. The input is processed in the widget instead since we’ve given it to the UI exclusively - Set Input Mode UI Only You can have it processed by both (widgets go first, though) with Set Input Mode Game and UI node but if you’re making a first person shooter kind of game (…

* * *

I see you’re using `Input Mode Game and UI` but it’s pretty much the same case. You grant Character Sheet focus - the PC cannot process input unless the widget loses it. Clicking on the screen does it, the PC gets focus back and the ability to process input again.

* * *

Consider implementing the Tab → Close in the widget. Or do not give the widget focus in the first place. Kind of depends on how you need the whole thing to work.

---

<div class="post-metadata">

**Author:** ![GernalIeal](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gernalieal/32/1182908_2.png) [@GernalIeal](https://forums.unrealengine.com/u/GernalIeal)\
**Post date:** [March 22, 2022, 11:58am UTC](https://forums.unrealengine.com/t/keyboard-loses-focus-when-opening-hud-element/508852/3 "2022-03-22T11:58:21Z")

</div>

I was using a flip/flop, clearly not the way!

I followed the link and while it does work, the UI seems to stretch across the whole screen which is not intended

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/f/7cfec75f6fb0adce0c1311a977e3112159e68ad7.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 22, 2022, 12:00pm UTC](https://forums.unrealengine.com/t/keyboard-loses-focus-when-opening-hud-element/508852/4 "2022-03-22T12:00:01Z")

</div>

This has little to do with the original issue, though. Either use a canvas and place elements there or:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/0/fc01a10432e5f9286038f725ef07aef0c73fb0e7.png)
