how to get KEY_A (or any other key) just pressed?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Thakee Nathees

I want to know a certain key like KEY_A or KEY_B is just pressed, but there is a method for checking action Input.is_action_just_pressed() is there any wat to implement is_key_just_pressed()?

:bust_in_silhouette: Reply From: Aspenforest

InputEvent - What is it?

:bust_in_silhouette: Reply From: Dlean Jeans

Try this:

func _input(event):
    var just_pressed = event.is_pressed() and not event.is_echo()
    if Input.is_key_pressed(KEY_A) and just_pressed:
        do_thing()

This actually works quite well. Thanks dude!

rico345100 | 2019-10-30 17:00

For me it does not do anything…

is there another thing to do to make the input function itself work?

or must there be something different in v3.4.3?

Drachenbauer | 2022-03-31 20:49