How to make "pressed" signal only work with one key

Godot Version

Godot 3.5


I am creating a part of a game, where I’m controlling one unit, and by pressing a button, I control another unit and vice versa. I use the space key to jump and WASD to move and then left mouse click to press the buttons. My problem is this:
After having moved around with my unit and jumped a bit, I want to change control by pressing the texture button, but now, all of a sudden, when I press the spacebar, I don’t only jump, but I also switch units. I want the button to only work when I use left click on it. Is there a way to make it so that the “pressed” signal only gets emitted when I use left click on it? And if it’s possible to do so without adding more code (like somewhere in the project settings?) or only a minimal amount, that would be appreciated.

Make that button’s Control.focus_mode to None.

Thank you so much!

Though I don’t really know what the focus_mode does (it doesn’t really seem to be very clear in the documentation), so if you (or someone else) could explain to me what it is, I’d really appreciate it, thank you ^^

Focused component can capture keyboard input, and other input.
For example, when you are typing, the input box is focused by you so you can type.
In browser, use tab and shift+tab key can toggle focus.
That’s why visually impaired people can view web pages with just a few buttons.
In your case, when you clicked that button, the button became the focus, it captured your keyboard input.

Thank you so much for the clarification!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.