Is it possible to only respawn when a button is pressed?

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if IsControlJustPressed(1, 18) and IsPlayerDead(ped) then
        	revivePed()
        	TriggerEvent("chatMessage", "::", {255, 0, 0}, "^1Revived :::")
        end
    end
end)

function revivePed(ped) -- Credits to @Turtle
	local ped = GetPlayerPed(-1)
	local playerPos = GetEntityCoords(ped, true)

	NetworkResurrectLocalPlayer(playerPos, true, true, false)
	SetPlayerInvincible(ped, false)
	ClearPedBloodDamage(ped)
end