Game Bucks

Disable ALT-F4 In Game

So, I just wanted to disable this command in game because it would cause more problems during the gameplay of Darkraze. I am going to share both versions of this script since it is INSANELY short. Anyway, here it is:


  1. Create a new script (if using C#, don’t forget to rename the script to the class name)
  2. Create a new empty GameObject IN THE FIRST SCENE (scene number 0) (you can check the scene number in the Build Settings).
  3. Attach this script to that GameObject.
using UnityEngine;
using System.Collections;

public class DisableQuitHotkey : MonoBehaviour {
	void Awake() {
                //We want to keep this script throughout the entire game.
	void OnApplicationQuit() {
                //Assuming that you are trying to hit Alt-F4. (I've tried adding GetKey(KeyCode.F4) but it doesn't work that way, trust me).
		if(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) {

Game Bucks

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.