Disable Windows (and other) keys

Godot Version

4.4

Question

I’m making a game/educational app for my daughter. The kind you press a key and the program says the name of the letter out loud.

The problem is that she sometimes presses the windows key or others (esc, alt…) and then the program goes back to the OS.

Is there a way to disable those keys?
I know some games have a toggle in the setup that does that but I’m not sure if i can do that with Godot.

Thank you very much!

Some OS-level shortcuts (Ctrl+Alt+Del, Alt+F4, etc.) can’t be disabled for security reasons. Which shortcuts do you exactly talking about?

Does the app has some unique keys like ESC to close, etc?

I would like to disable mainly the windows key and alt+tab.
Ideally any key that it’s not a letter.
Right now I can close the app with a function I wrote that quits the program if you hold Esc for 3 seconds.

You can try setting the window mode to fullscreen like this:

DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)  

Otherwise, as far as I know, you can block quitting the app using shortcuts like Ctrl + W, etc. However, I’m not sure how to block the Windows key, it may not be possible.

What are you trying to achieve here? Because I’ll be honest, as a player, this would make me not want to ever play your game. It’s annoying enough that some modern titles don’t respect Alt + F4 anymore, but taking away my ability to multitask is a huge nono and I cannot think of any reason why you’d want to do this.

I said it in the first post. Disabling the windows key so my daughter of 2 years doesnt exit the app accidentally. Its a custom made app just for her, not for everyone else.

1 Like

Already tried that without luck. Thank you anyway!

1 Like

In that case it might be a better idea to globally disable these shortcuts during time runtime of the application, see:

But do be careful with these modifications, and make sure you first understand how to revert them.