Globally catch keypress

Godot Version

v4.3.stable.official [77dcf97d8]

Question

Is there a way for my base scene’s script to detect all keypresses? That might not be the right thing to do for what I am trying to achieve.

What I actually want is that when a dialogue is running using GitHub - nagidev/DialogueNodes: A plugin for creating, editing and using branching dialogues in Godot When the user presses the spacebar the display speed is doubled. And when they release it the display speed returns to normal.

I think what I need to do is have my base scene’s script catch the space keypress then test if dialogue is running. If it is, increase speed. If it’s not, pass the event on to anything else what wants the spacebar. Then on space keyrelease test if dialogue is running, if it is reset speed back to normal.

How do I go about doing that? Or is there a better way to do this?

I would create an InputManager that exist in the root of your SceneTree.
It has a _process() or _input() method that listen to everything you do.
There needs to be a system that detects if an InputAction is pressed and held down, also detecting the moment the InputAction is released. Based on the inputs, the InputManager can emit signals that can alter other scripts. If not by use of signals, I would just make use of a Global autoload that has tons of global variables such as Global.display_speed

then again, it heavily depends on how the display speed is affecting the game. If it’s done via tweens, or animationplayer, or something else.