+3 votes
    if (Input.action_press("key_left")):

in fixed process does nothing, is there a way to execute the if statement only on the key press and not execute it over and over while being pressed?

in Engine by (129 points)

This is a similar question, and a similar answer:

https://godotengine.org/qa/8760/disable-autoshot-on-keypress

2 Answers

+2 votes
Best answer

Monitoring for an event within func _input will work, as long as "key_left" if defined in your input map.

func _ready():
    set_process_input(true)

func _input(event):
    if event.is_action_pressed("key_left"): print("left key pressed")
by (1,318 points)
selected by
0 votes

I use this utility:
https://github.com/godotengine/godot/issues/4514#issuecomment-217495690

The development version has Input.is_action_just_pressed and Input.is_action_just_released if you don't care to work with non stable version.

by (7,948 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.