How to prevent keyboard input when running game in background?

There are some keys for inputting in my pc game,when the game was minimized in taskbar ,I dont want the game to receive any input like keyboard input. I unchecked the “running in background” option,but it does not work. So how to resolve this?

There may be some built-in way to do this but I would just implement good old OnApplicationFocus() and set a boolean that controls if input is processed or ignored.

1 Like