In my game players could play via controllers and a keyboard.

When player is disconnected I would like to pause the game. I can easily detect controller disconnection event via the JoyConnectionChanged event

    public override void _Ready()
    {
        Input.JoyConnectionChanged += JoyConnectionChanged;
    }

    private void JoyConnectionChanged(long device, bool connected)
    {
        GD.Print("Device " + device + " is connected? " + connected);
    }

Is there a similar way to determine if a keyboard got disconnected?

cybereality as Sosasees mentioned it could be for a reason of switching keyboards. Or just the loosely cable making the keyboard go on and off.. Am I correct to assume from your response that such feature does not exist?

I doubt anyone considered that use case as it is very strange and uncommon for a user to unplug their keyboard or mouse in the middle of playing a game.

    cybereality Well, it's the same with controllers. How many times has the battery died on my wireless controller? Plenty of times. Nowadays, people tend to use wireless devices, including wireless keyboards. If a keyboard gets disconnected for whatever reason, it can cause the player to experience some unpleasant consequences in a fast-paced game.

    I think it's a very good use-case and reason for adding support for disconnect events for keyboards. I will consider creating a feature request for Godot a bit later 🙂