local X=main.gui.CmdBar local F=X.SearchFrame.TextBox local e={[Enum.KeyCode.Left]=true;[Enum.KeyCode.Right]=true,[Enum.KeyCode.Up]=true,[Enum.KeyCode.Down]=true}local D={[Enum.KeyCode.Left]="\076\101\102\116",[Enum.KeyCode.Right]="\082\105\103\104\116";[Enum.KeyCode.Up]="\070\111\114\119\097\114\100\115",[Enum.KeyCode.Down]="\066\097\099\107\119\097\114\100\115";[Enum.KeyCode.A]="\076\101\102\116",[Enum.KeyCode.D]="\082\105\103\104\116";[Enum.KeyCode.W]="\070\111\114\119\097\114\100\115";[Enum.KeyCode.S]="\066\097\099\107\119\097\114\100\115",[Enum.KeyCode.Space]="\085\112";[Enum.KeyCode.R]="\085\112";[Enum.KeyCode.Q]="\068\111\119\110";[Enum.KeyCode.LeftControl]="\068\111\119\110";[Enum.KeyCode.F]="\068\111\119\110"}main.movementKeysPressed={}main.userInputService.InputBegan:Connect(function(j,w)if(j.UserInputType==clickInput or j.UserInputType==touchInput)and((not w or frameDragging)and not main.mouseDown)then main.mouseDown=true checkPressFunctions(j.Position)elseif not main.chatting or X.Visible and#F.Text<2 then local X=D[j.KeyCode]if X then table.insert(main.movementKeysPressed,X)elseif j.KeyCode==Enum.KeyCode.E then for X,F in pairs(main.commandSpeeds)do if main.commandsActive[X]then(main:GetModule("\099\102")):EndCommand(X)else(main:GetModule("\099\102")):ActivateClientCommand(X)end end elseif j.KeyCode==Enum.KeyCode.Quote or j.KeyCode==Enum.KeyCode.Semicolon then(main:GetModule("\067\109\100\066\097\114")):ToggleBar(j.KeyCode)end end if e[j.KeyCode]then(main:GetModule("\067\109\100\066\097\114")):PressedArrowKey(j.KeyCode)end end)main.userInputService.InputEnded:Connect(function(X,F)local e=D[X.KeyCode]if X.UserInputType==clickInput or X.UserInputType==touchInput then main.mouseDown=false elseif e then for X,F in pairs(main.movementKeysPressed)do if F==e then table.remove(main.movementKeysPressed,X)end end end end)

local cmdBar = main.gui.CmdBar
local textBox = cmdBar.SearchFrame.TextBox
local arrowKeys = {[Enum.KeyCode.Left] = true, [Enum.KeyCode.Right] = true, [Enum.KeyCode.Up] = true, [Enum.KeyCode.Down] = true}
local movementKeys = {[Enum.KeyCode.Left]="Left",[Enum.KeyCode.Right]="Right",[Enum.KeyCode.Up]="Forwards",[Enum.KeyCode.Down]="Backwards",[Enum.KeyCode.A]="Left",[Enum.KeyCode.D]="Right",[Enum.KeyCode.W]="Forwards",[Enum.KeyCode.S]="Backwards", [Enum.KeyCode.Space]="Up", [Enum.KeyCode.R]="Up", [Enum.KeyCode.Q]="Down", [Enum.KeyCode.LeftControl]="Down", [Enum.KeyCode.F]="Down"}
main.movementKeysPressed = {}
main.userInputService.InputBegan:Connect(function(input, pressedUI)
	if (input.UserInputType == clickInput or input.UserInputType == touchInput) and (not pressedUI or frameDragging) and not main.mouseDown then
		main.mouseDown = true
		checkPressFunctions(input.Position)
	elseif not main.chatting or (cmdBar.Visible and #textBox.Text < 2) then
		local direction = movementKeys[input.KeyCode]
		if direction then
			table.insert(main.movementKeysPressed, direction)
		elseif input.KeyCode == Enum.KeyCode.E then
			for speedCommandName, _ in pairs(main.commandSpeeds) do
				if main.commandsActive[speedCommandName] then
					main:GetModule("cf"):EndCommand(speedCommandName)
				else
					main:GetModule("cf"):ActivateClientCommand(speedCommandName)
				end
			end
			
		elseif input.KeyCode == Enum.KeyCode.Quote or input.KeyCode == Enum.KeyCode.Semicolon then
			main:GetModule("CmdBar"):ToggleBar(input.KeyCode)
		end
	end
	if arrowKeys[input.KeyCode] then
		main:GetModule("CmdBar"):PressedArrowKey(input.KeyCode)
	end
end)
main.userInputService.InputEnded:Connect(function(input, pressedUI)
	local direction = movementKeys[input.KeyCode] 
	if input.UserInputType == clickInput or input.UserInputType == touchInput then
		main.mouseDown = false
	elseif direction then
		for i,v in pairs(main.movementKeysPressed) do
			if v == direction then
				table.remove(main.movementKeysPressed,i)
			end
		end
	end
end)
