function KeyDown(Z)local N=string.lower(Z)if N==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 N==S.RaiseStanceKey and S.CanChangeStance then if not Running then if Stance==2 then Crouch()elseif Stance==1 then Stand()end end end if N==S.ADSKey then if S.HoldMouseOrKeyToADS then if not AimingIn and not Aimed then AimingIn=true AimGun()AimingIn=false end else if Aimed then UnAimGun()else AimGun()end end end if N==S.ReloadKey then if not Reloading and not Running then Reload()end end if N==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 N==S.LethalGrenadeKey and S.Throwables then if not Knifing and(not Running and(not Aimed and(not Aiming and not ThrowingGrenade)))then if LethalGrenades.Value>0 then LethalGrenades.Value=LethalGrenades.Value-1 ThrowingGrenade=true ThrowGrenade(1)ThrowingGrenade=false end end end if N==S.TacticalGrenadeKey and S.Throwables then if not Knifing and(not Running and(not Aimed and(not Aiming and not ThrowingGrenade)))then if TacticalGrenades.Value>0 then TacticalGrenades.Value=TacticalGrenades.Value-1 ThrowingGrenade=true ThrowGrenade(2)ThrowingGrenade=false end end end if N==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(Z)local N=string.lower(Z)if N==S.ADSKey then if S.HoldMouseOrKeyToADS then if not AimingOut and Aimed then AimingOut=true UnAimGun()AimingOut=false end end end if N==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.ADSKey then
		if S.HoldMouseOrKeyToADS then
			if (not AimingIn) and not Aimed then
				AimingIn = true
				AimGun()
				AimingIn = false
			end
		else
			if Aimed then
				UnAimGun()
			else
				AimGun()
			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.LethalGrenadeKey and S.Throwables then
		if (not Knifing) and not Running and not Aimed and not Aiming and not ThrowingGrenade then
			if LethalGrenades.Value > 0 then
				LethalGrenades.Value = LethalGrenades.Value - 1
				ThrowingGrenade = true
				ThrowGrenade(1)
				ThrowingGrenade = false
			end
		end
	end

	if Key == S.TacticalGrenadeKey and S.Throwables then
		if (not Knifing) and not Running and not Aimed and not Aiming and not ThrowingGrenade then
			if TacticalGrenades.Value > 0 then
				TacticalGrenades.Value = TacticalGrenades.Value - 1
				ThrowingGrenade = true
				ThrowGrenade(2)
				ThrowingGrenade = false
			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.ADSKey then
		if S.HoldMouseOrKeyToADS then
			if (not AimingOut) and Aimed then
				AimingOut = true
				UnAimGun()
				AimingOut = false
			end
		end
	end

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