How to make jumping like hollow knight?

Godot Version

Godot 4.4.1

Question

I wanted to make the player character in a 2d game jump higher the longer you press the jump key, up to a certain height, but also with a lowest height. I have attempted to do so, but i just can get it to feel right. Here is the player movement code:

Code

extends CharacterBody2D


const SPEED_MAX = 200.0
const SPEED = 100
var JUMP_VELOCITY = 0

var gravity = 700
var ACCELERATION = 1.25
var Jumping = false


func _physics_process(delta: float) -> void:
	
	var direction := Input.get_action_strength("Walk_Right") - Input.get_action_strength("Walk_Left")
	
	if velocity.y <= 1700:
		velocity.y += (gravity * delta) + JUMP_VELOCITY


	if is_on_floor():
		if Input.is_action_just_pressed("Jump"):
			Jumping = true
	if Input.is_action_just_released("Jump"):
		Jumping = false
	if Jumping == true:
		if JUMP_VELOCITY >= -45:
			if JUMP_VELOCITY >= -1:
				
				JUMP_VELOCITY += -1 * 250 * delta
			else:
				JUMP_VELOCITY += -1 * 250 * delta
		else: 
			Jumping = false
	else:
		JUMP_VELOCITY = 0
	
	if direction:
		if ACCELERATION <= 2:
			ACCELERATION += 1.5 * delta
		else:
			ACCELERATION = 2
	else:
		ACCELERATION = move_toward(ACCELERATION, 1.25, 0.2)
	
	velocity.x = direction * (SPEED*ACCELERATION)
	
	print(JUMP_VELOCITY)

	move_and_slide()

I’ve used this video before.

thank you, I will watch this.

I once heard of a trick where you just set the player’s y velocity to 0 once the jump key is released.
I never tested this out, so i cant guarantee anything, but trying it out wont hurt imo