IsControlJustReleased() only detecting inputs while spamming key

Hey,

im trying to get this function to work. But it is not detecting me pressing E.
This is my script:

while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(55)
		if Vdist(coords, location) < 15 then
			isNear = true
			if Vdist(coords,location) < 3  then
				if IsControlJustReleased(2, 38) then
				print("E Presses")
				end
			end
		else
			isNear = false
		end
	end

Can someone help me? I tried to google it but it didnt work.

EDIT: When I spam E then it takes a input. How can I avoid this?

waiting 55ms is going to cause some missed presses. Pressing for longer gets it detected and making the wait smaller will cause it to check more often for a press occurring during it’s loop.

Citizen.Wait(55) change to Citizen.Wait(0)