How to fix unintentional near-frame-perfect double jump possibilty?

Godot Version

4.2.1 (Windows)


I’m currently developing a commercial indie game, and while the player code is going really smoothly, i’ve ran into one problem

When the player jumps, they can double jump by mashing the jump button fast in a short timeframe, I’ve tried to fix this by various ways but nothing seems to be working, do any of you got any ideas?

VIDEO: monochromiaearlydevfootage : DiamondCore Studios : Free Download, Borrow, and Streaming : Internet Archive
(start of video is normal jump, middle is the funky double jumping)

CODE (not full code, excluded unnecessary-to-add elements like walking code)

const JUMP_VELOCITY = -200.0
var jumpTimer = 0.0
var canJump = false

func defaultJump(delta):
if Input.is_action_just_pressed(“ui_accept”):
jumpTimer = 0.1
jumpTimer -= delta
if jumpTimer > 0 and canJump:
jumpTimer = 0.0
velocity.y = JUMP_VELOCITY
if Input.is_action_just_released(“ui_accept”) and velocity.y < 0.0:
velocity.y = 0.0

if is_on_floor() and canJump == false:
	canJump = true
elif canJump == true and $Coyote.is_stopped():

You are never setting canJump to false.