# Focused window hides key bindings

**URL:** <https://forums.unrealengine.com/t/focused-window-hides-key-bindings/486064>\
**Category:** Community & Industry Discussion\
**Tags:** focus, unreal-engine, slate, Plugins, question, key-bind\
**Created:** [July 11, 2021, 8:51pm UTC](https://forums.unrealengine.com/t/focused-window-hides-key-bindings/486064 "2021-07-11T20:51:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_1a46ad78](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1a46ad78](https://forums.unrealengine.com/u/anonymous_user_1a46ad78)\
**Post date:** [July 11, 2021, 8:51pm UTC](https://forums.unrealengine.com/t/focused-window-hides-key-bindings/486064/1 "2021-07-11T20:51:57Z")

</div>

I’m writing a plugin. I create a window and do some stuff in it.

I want to close my window when the user presses some keys that would bind to some command if my plugin window wasn’t in focus. For example, if my plugin window is focused and the user presses Ctrl + Alt + S that would close my plugin window and open the “Save Level As” window. But if there is no registered command for pressed keys, I don’t need to close my window.

My plugin window is inherited from **SWindow** class, so I can override _onKeyDown_, _onKeyUp_ or _onKeyChar_ functions from that.

I ran out of ideas on how to do this. These are some ideas that came to my mind, but I failed:

1. I tried to use **FInputBindingManager** in overridden _OnKeyDown_ function, call _FInputBindingManager::Get().GetKnownInputContexts(Contexts)_ and check if any of found Contexts contains command for user’s keyboard chord with _FindCommandInContext_ command. But after I found Context that contains the user’s chord, I don’t know what to do with it, how can I call this command, after I close my plugin window.
2. I was thinking about changing the focus before processing keybinding, because in _FSlateApplication:::ProcessKeyDownEvent_ they call _OnKeyDown_ function on focus path with bubble policy, and if the previous window will be in focus, it handles the user’s chord properly. The only idea of how I can do this is to change the focus path in the _OnPreviewKeyDown_ overridden function of my window class, which will be called in _FSlateApplication::ProcessKeyDownEvent_ for each focused widget before calling _OnKeyDown_. But the problem is that in _FSlateApplication::ProcessKeyDownEvent_ the focusePath will not change after this, and plus I don’t know how can I return focus to my window in case that key binding is invalid (because no one will call me back after trying to process key binding if I lose focus).

I will appreciate any help and ideas on how I can do this.
