Close UI with input actions

Hello Everyone,

I am learning Unreal and have an issue i cannot figure out. So basically i use the new ehnanced input system where I call an EnhancedInputAction to open a widget. I set the visibility and the input mode to UI only. So far so good.
However, i cannot manage to be able to close the widget after with this enhanced input action.
I could use the “On key down” override but this would prevent the player to rebind the keys.

My question would be : how can my player be able to close the widget by pressing the same key as to open it and that he can change the keys during game.

Can i trigger a enhancedinputaction into the widget or Can i get the key used by the enhanced input action to compare it to the on key down function ?

Or if you have any other idea to handle it feel free.

Thks everyone for your help in advance.

You can do the check inside the player controller,
EnhancedKeyInventory: if PlayerMenuWidget is not in viewport, visibility = True otherwise it hidden.

image

You’d have to set controller to game and UI input and run a check like arodi mentioned on that input event