How can i check if a button is presssed? (code: https://pastebin.com/LGbw8UcW)

Godot Version

Godot 4.4

Question

How can i check if a button is pressed and what button is pressed
if i use pressed it keeps getting presssed and the button isnt a toggle button
(code in the pastebin link)

You’ll want to just connect the button pressed signal to a signal handler function. The function will be called each time the button is pressed. There, you can add code to do whatever you need.

Maybe use an

Input.is_action_just_pressed(“whatever_button”):

To detect?
Just make sure to not do:

Input.is_action_pressed(“whatever_button”):

And for some reason i cant press your pastebin link

what do you mean by connect the signal? My buttons are created at runtime.

the pastebin link should work now, I don’t mean by button a key on the keyboard or controller, i mean an ui button,I’m struggling with it because the buttons are created in runtime

1 Like