I wanted to avoid using Blueprints at all so looked into how to do this using C++.
I’m not sure if this is the optimal solution. Maybe there’s better one for C++.
But in any case it works just fine:
- Create a new C++ class based on APlayerController.
- Implement Tick and use the WasInputKeyJustPressed method there.
Since this is called each frame I added a IsMenuOpen flag to prevent running this multiple times. The flag is reset when the menu is closed (not shown here).