• Godot Help
  • Godot application detect hotkey when window is not in focus

How can I detect hotkeys or user input even if the application is not in focus?
I'm pretty sure that this is not possible out of the box but are there any addons or how can I archive this?

The application is open on another monitor but not focused (not sure if that makes a difference...)

No, this is not really possible (nothing with Godot, just how operating systems work).

There are some weird/hack ways to do it but it's not really a good user experience.

    cybereality How about a Godot application detecting when it's not the active window? I haven't looked into it at all, but since this thread is here..

    • 7892 replied to this.

      cybereality
      Its for a privat project only so I dont mind some hacky workarounds.
      And there are a lot of applications that use hotkeys even when not focused (e.g. Spotify, OBS, Discord...). You cannot tell me that they use some hacky workarounds 😃

      packrat
      Thats easily possible but how would that help?

        7892 And there are a lot of applications that use hotkeys even when not focused (e.g. Spotify, OBS, Discord...).

        Virtually all screen capture software. Also many players.

        Yes, like I said, you could do it, but you need to use OS level code, like with C/C++.

        • 7892 replied to this.

          packrat
          https://docs.godotengine.org/en/stable/classes/class_mainloop.html

          func _notification(what):
          	if what == MainLoop.NOTIFICATION_APPLICATION_FOCUS_OUT:
          		print("FOCUS_OUT")
          	elif what == MainLoop.NOTIFICATION_APPLICATION_FOCUS_IN:
          		print("FOCUS_IN")

          cybereality
          Do you have any source where I can read more about it or any tutorials?
          Or any Keywords I should search for?