function KeyDown(k)local w=string.lower(k)if w==S.LowerStanceKey and S.CanChangeStance then if not Running then if Stance==0 then Crouch()elseif Stance==1 then Prone()end elseif S.DolphinDive then delay(.033333333333333,function()CanRun=false Dive(S.BaseWalkSpeed)Run_Key_Pressed=false wait(S.DiveRechargeTime)CanRun=true end)end end if w==S.RaiseStanceKey and S.CanChangeStance then if not Running then if Stance==2 then Crouch()elseif Stance==1 then Stand()end end end if w==S.ReloadKey then if not Reloading and not Running then Reload()end end if w==S.KnifeKey and S.CanKnife then if KnifeReady and(not Knifing and not ThrowingGrenade)then if Aimed then UnAimGun(true)end BreakReload=true Knifing=true KnifeReady=false KnifeAnim()BreakReload=false Knifing=false delay(S.KnifeCooldown,function()KnifeReady=true end)end end if w==S.SprintKey then Run_Key_Pressed=true if Aimed and not Aiming then TakingBreath=false SteadyCamera()end if CanRun then if not Idleing and(Walking and(not Running and(not Knifing and not ThrowingGrenade)))then if Reloading then BreakReload=true end MonitorStamina()end end end end function KeyUp(k)local w=string.lower(k)if w==S.SprintKey then Run_Key_Pressed=false Running=false if not ChargingStamina then RechargeStamina()end end end
--------------------[ KEYBOARD FUNCTIONS ]--------------------------------------------

function KeyDown(K)
	local Key = string.lower(K)

	if Key == S.LowerStanceKey and S.CanChangeStance then
		if not Running then
			if Stance == 0 then
				Crouch()
			elseif Stance == 1 then
				Prone()
			end
		elseif S.DolphinDive then
			delay(1 / 30, function()
				CanRun = false
				Dive(S.BaseWalkSpeed)
				Run_Key_Pressed = false
				wait(S.DiveRechargeTime)
				CanRun = true
			end)
		end
	end

	if Key == S.RaiseStanceKey and S.CanChangeStance then
		if not Running then
			if Stance == 2 then
				Crouch()
			elseif Stance == 1 then
				Stand()
			end
		end
	end

	if Key == S.ReloadKey then
		if (not Reloading) and not Running then
			Reload()
		end
	end

	if Key == S.KnifeKey and S.CanKnife then
		if KnifeReady and not Knifing and not ThrowingGrenade then
			if Aimed then
				UnAimGun(true)
			end
			BreakReload = true
			Knifing = true
			KnifeReady = false
			KnifeAnim()
			BreakReload = false
			Knifing = false
			delay(S.KnifeCooldown, function()
				KnifeReady = true
			end)
		end
	end

	if Key == S.SprintKey then
		Run_Key_Pressed = true
		if Aimed and not Aiming then
			TakingBreath = false
			SteadyCamera()
		end
		if CanRun then
			if (not Idleing) and Walking and not Running and not Knifing and not ThrowingGrenade then
				if Reloading then
					BreakReload = true
				end
				MonitorStamina()
			end
		end
	end
end

function KeyUp(K)
	local Key = string.lower(K)

	if Key == S.SprintKey then
		Run_Key_Pressed = false
		Running = false
		if not ChargingStamina then
			RechargeStamina()
		end
	end
end
