0 votes

Is there a way to do this in GD script rather than getting is_key_pressed is there something along the lines of is_key_released?

in Engine by (484 points)

2 Answers

+8 votes

Call set_process_input(true) inside your _ready function
You can then do this in your_input function, after calling :

func _input(event):
# ...
    if event.type == InputEvent.KEY:
    # ...
        if event.scancode == KEY_W && event.pressed == false:
        # The 'W' key was released
by (81 points)
+3 votes

Use actions instead of hard coding keys. Then just do:

func _input(event):
    if event.is_action_released("my_action"):
        do_other_stuff()

and for key pressed use if event.is_action_pressed()

by (542 points)
edited by
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.
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 webmaster@godotengine.org with your username.