[UE5.1.1] How To Bind UI-Only Input Actions?

I’m trying to set up my UI menus so that they have hotkeys that function only while the menu is open. Currently, I have an InputMappingContext and InputAction assigned to properties on the menu widget class. When the menu is added to the viewport, I add the mapping context to the EnhancedInputLocalPlayerSubsystem and bind the input action to the EnhancedInputComponent. Then I remove the mapping context and input action when the menu is removed from the viewport.

The problem that I’m having is that if I set the Input Mode to “Game and UI,” it allows the player to do things like aim down sights, which they shouldn’t be able to do when the menu is open. However, if I set the input mode to “UI Only” then the input action I just set up doesn’t work. Does anyone know of a solution for this?

I’ve used “Bind Event to Button Command” in older versions of Unreal, then set the commands using custom events. Unfortunately I haven’t looked into doing it with Enhanced Input Actions.

Did you figure this out by chance?

Yes, I just had to override NativeOnKeyDown from the UUserWidget class.