local v=main.gui.CmdBar local R=v.SearchFrame.TextBox local E={[Enum.KeyCode.Left]=true,[Enum.KeyCode.Right]=true;[Enum.KeyCode.Up]=true;[Enum.KeyCode.Down]=true}local e={[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(U,Z)if(U.UserInputType==clickInput or U.UserInputType==touchInput)and((not Z or frameDragging)and not main.mouseDown)then main.mouseDown=true checkPressFunctions(U.Position)elseif not main.chatting or v.Visible and#R.Text<2 then local v=e[U.KeyCode]if v then table.insert(main.movementKeysPressed,v)elseif U.KeyCode==Enum.KeyCode.E then for v,R in pairs(main.commandSpeeds)do if main.commandsActive[v]then(main:GetModule("\099\102")):EndCommand(v)else(main:GetModule("\099\102")):ActivateClientCommand(v)end end elseif U.KeyCode==Enum.KeyCode.Quote or U.KeyCode==Enum.KeyCode.Semicolon then(main:GetModule("\067\109\100\066\097\114")):ToggleBar(U.KeyCode)end end if E[U.KeyCode]then(main:GetModule("\067\109\100\066\097\114")):PressedArrowKey(U.KeyCode)end end)main.userInputService.InputEnded:Connect(function(v,R)local E=e[v.KeyCode]if v.UserInputType==clickInput or v.UserInputType==touchInput then main.mouseDown=false elseif E then for v,R in pairs(main.movementKeysPressed)do if R==E then table.remove(main.movementKeysPressed,v)end end end end)
--Click/Touch
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)
