# How can I catch alt f4 key in ue5?

**URL:** <https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624>\
**Category:** International\
**Tags:** unreal-engine, UE5-0, question\
**Created:** [November 19, 2022, 8:46pm UTC](https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624 "2022-11-19T20:46:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sherzod17](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sherzod17](https://forums.unrealengine.com/u/Sherzod17)\
**Post date:** [November 19, 2022, 8:46pm UTC](https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624/1 "2022-11-19T20:46:10Z")

</div>

Help

---

<div class="post-metadata">

**Author:** ![EliasWick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eliaswick/32/1175208_2.png) [@EliasWick](https://forums.unrealengine.com/u/EliasWick)\
**Post date:** [November 20, 2022, 11:38am UTC](https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624/2 "2022-11-20T11:38:04Z")

</div>

I believe it is a universal windows key combination and can’t be catches unless you override the default behaviour for the WM\_CLOSE message. This will require C++.

---

<div class="post-metadata">

**Author:** ![Neyl\_S](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neyl_s/32/263712_2.png) [@Neyl\_S](https://forums.unrealengine.com/u/Neyl_S)\
**Post date:** [November 20, 2022, 12:49pm UTC](https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624/3 "2022-11-20T12:49:02Z")

</div>

> **[AActor::EndPlay](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/GameFramework/AActor/EndPlay/)**
>
> Overridable function called whenever this actor is being removed from a level

or

> **[UGameEngine::PreExit](https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/Engine/UGameEngine/PreExit/)**
>
> Called at shutdown, just before the exit purge.

---

<div class="post-metadata">

**Author:** ![JoostDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joostdev/32/88718_2.png) [@JoostDev](https://forums.unrealengine.com/u/JoostDev)\
**Post date:** [August 17, 2023, 8:29am UTC](https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624/4 "2023-08-17T08:29:25Z")

</div>

According to this post, it can be done:

> [@Catching/Blocking Alt+f4 in Packaged Game](https://forums.unrealengine.com/t/catching-blocking-alt-f4-in-packaged-game/348273/5):
>
> Actually you can also handle window close requests in user code, without ever touching the engine source. The viewport client does have a delegate for exactly that purpose, which can be obtained by the UGameViewportClient::OnWindowCloseRequested() accessor. The world viewport client can be obtained with the UGameInstance::GetGameViewportClient() method, but beware that this is only available after the GameInstance has been initialized, but not yet in the UGameInstance::Init() method. So, as c…

---

<div class="post-metadata">

**Author:** ![ShadowBr0kerz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shadowbr0kerz/32/1201558_2.png) [@ShadowBr0kerz](https://forums.unrealengine.com/u/ShadowBr0kerz)\
**Post date:** [October 21, 2026, 1:19pm UTC](https://forums.unrealengine.com/t/how-can-i-catch-alt-f4-key-in-ue5/694624/5 "2026-10-21T13:19:57Z")

</div>

alt+f4 never reaches the input system as a key, windows turns it into a WM\_CLOSE message so no key binding can catch it. the engine hook is UGameViewportClient::OnWindowCloseRequested, bind it after the game instance is up and return false and the close is ignored. that only covers a graceful close though, a kill from task manager or a crash never passes through that delegate. you can also try Kiosk Lockdown Toolkit, a kiosk mode plugin for Unreal Engine that swallows alt+f4 at the OS layer before it ever becomes a close request: [Kiosk Lockdown Toolkit — Block Alt+Tab, Win Key & Taskbar for Kiosks | Fab](https://www.fab.com/listings/c91c6583-6eea-412b-ae64-248ddd69f731)
