Focused window hides key bindings

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.