+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?

asked Oct 20, 2016 in Engine by blank (130 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")
answered Oct 20, 2016 by ericdl (1,284 points)
selected Oct 21, 2016 by blank
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.

answered Oct 21, 2016 by eons (7,764 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 How to use this Q&A? before posting your first questions.