0 votes

i want get status of press
if Input.iskeypressed(KEY_A):

↑i want get status of while pressed

in Engine by (200 points)

1 Answer

0 votes

The code you suggests works when using the correct methods and placing it in _process:

extends Node

var pressed = false

func _process(delta):
    pressed = Input.is_key_pressed(KEY_A)
    if pressed:
    elif not pressed:
        print("not pressed")

However, this is usually done using Input event handlers and Input mapping.

The Godot "Your First Game" tutorial shows how to do this properly:
Godot 3.1 Your First Game

by (61 points)

thanks for comment
i understand it

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.