Incoherent PlayerInput behavior between UGameViewportClient::LostFocus and UGameViewportClient::ReceivedFocus

I’m working on input handling in my game and i’m facing an unexpected behavior when GameViewport looses the focus (either when i alt+tab outside the game windows or when i give focus to any of my UMG widget)

void UGameViewportClient::LostFocus(FViewport* InViewport)

calls

PlayerController->FlushPressedKeys();

that clears out any pressed input (keyboard key and gamepad button)

void UGameViewportClient::ReceivedFocus(FViewport* InViewport)

Does not refresh which keys and gamepad buttons are currently pressed…

I want my Character to crouch only when the player hold a button so i’m listening to IE_Pressed / IE_Released to toggle crouch but UGameViewportClient::LostFocus calls IE_Released on everything even if the key is still down.

If i hold “crouch”, open a menu and come back to the game the crouch button is considered as released even if it is still down, I must release and press it again to get my character crouched.

Is there a way to force PlayerInput to refresh its keydown when UGameViewportClient receive focus again ?

Hey Cø-

If I understand correctly you’re saying that when focus is lost that the couch key is considered ‘released’ but when focus returns it doesn’t check that the key is still being held nor trigger the ‘pressed’ event? I have submitted a report for this (UE-13755) functionality to be updated.

Cheers