Keep game running while tabbed out

I want the Input.GetKeyDown() to still work while tabbed out. Is this possible?

If you need it, here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class andahhh : MonoBehaviour {
    public Text number;
    public Text title;
    public InputField changeTitle;

    // Use this for initialization
    void Start () {
        Application.runInBackground = true;
        number.text = "0";
        changeTitle.text = "Button Press Count:";
    }
   
    // Update is called once per frame
    void Update () {
        if(Input.GetKeyDown(KeyCode.RightControl))
        {
            int newNumber = (int.Parse(number.text.ToString())) + 1;
            number.text = newNumber.ToString();
        }

        title.text = changeTitle.text;
    }


}

Edit → Project Settings → Player → Resolution and Presentation → “Run in Background” is I think all you can do from the Unity side. That’ll make it so that Unity keeps updating frames even while unfocused, but the part where Unity actually receives input… I don’t know. It may work just by checking that box, it may require getting “raw” input data instead of the event kind, or it may require redirecting input through the OS using a separate tool of some kind.

Sorry I can’t be more help.

EDIT: Just found this, may be of some help.

I was curious about this and knew it was possible, but had never done it.
I found a sample project: https://code.msdn.microsoft.com/CSRegisterHotkey-e3f5061e

Doing cover every type of hook, but should suffice for hotkeys like you were asking. :slight_smile:

I didn’t actually look at this code or test it, just fyi. :slight_smile: