Enum.UserInputType and Enum.KeyCode in same in pairs loop

What would be the best way to make both of the Enum types work in the same in pairs loop? I can’t think of a proper way to make anything besides keys fire the remote.

You could compare both fields of the input object perhaps.

if Input.KeyCode == v or Input.UserInputType == v then
--//input detected
end
1 Like

If you plan on having a lot of keybinds which belong to both “KeyCode” and “UserInputType”, to prevent unnecessarily checking “KeyCode” even if the input was a “UserInputType” and vice versa you could do the following:

local binds1 = {} --keycode binds
local binds2 = {} --userinputtype binds

if Input.KeyCode then
	for i, v in pairs(binds1) do
		if Input.KeyCode == v then
			--do code
		end
	end
elseif Input.UserInputType then
	for i, v in pairs(binds2) do
		if Input.UserInputType == v then
			--do code
		end
	end
end