How to make one button do two different things?

Godot Version

4.2.2

Question

I am making a rougelite game and I want the controls to be as simple as possible. There are two movements, a dash and a dodge, that I want to have the same button to activate. Dash when you press, and dodge when you tap. Is there a way to do this in godot?

Is the game real time or turn based? Should the dash or dodge start when you press the button or when you release it?

real time. To dash you have to hold it down. To dodge you have to quickly press and release.

So if I understand correctly, when you press the button, the character starts a dash, but if you release the button within a certain time frame, the dash turns into a dodge.

You could add a timer node for dodging and do somethin like this.

@onready var dodge_timer = $DodgeTimer
enum {IDLE, WALKING, DASHING, DODGING}
var state = IDLE

func _physics_process(delta):
    if state != DASHING and Input.is_action_just_pressed("action_name"):
        state = DASHING
        # insert code for dashing
        dodge_timer.start()
    if state == DASHING and not dodge_timer.is_stopped() and Input.is_action_just_released("action_name"):
        state = DODGING
        # insert code for dodging