Start typing to search packages!
InputController
Central input handler. Bind sets of keys, gamepad buttons, or GuiButtons to named maps, listen for activation through signals, and track the current input type.
Initialization happens automatically on first require. The module is client only.
Usage
local InputController = require(Packages.InputController)
local jump = InputController:Bind({ Enum.KeyCode.Space, Enum.KeyCode.ButtonA })
jump.Began:Connect(function(activator)
-- input pressed
end)
jump.Ended:Connect(function(activator)
-- input released
end)
Maps
Every bind belongs to a map. Bind uses the "Default" map and BindToMap targets a named one. Disabling a map stops all of its binds from firing, which is handy for turning off gameplay input while a menu is open.
InputController:SetMapEnabled("Gameplay", false)
API
InputController:Bind(enums)
Binds a set of KeyCodes, UserInputTypes, or GuiButtons to the "Default" map. Returns an InputContainer.
InputController:BindToMap(mapName, enums)
Same as Bind but targets a named map. Returns an InputContainer.
InputController:Unbind(container)
Removes a container returned by Bind or BindToMap from its map and disconnects it.
InputController:SetMapEnabled(mapName, enabled)
Enables or disables every bind under a map.
InputController:GetCurrentInputType()
Returns the current input type, one of "Keyboard", "Touch", or "Gamepad".
InputController:OnInputTypeChanged(callback)
Runs the callback with the new input type whenever it changes. Returns a connection.
InputController:GetGamepadInputState(keyCode)
Returns the live InputObject for a gamepad KeyCode, or nil.
InputController.CurrentInputType
The current input type. Set as soon as the module is required.
InputController.InputTypeChangedSignal
Fires with the new input type when it changes.
InputContainer
Returned by Bind and BindToMap.
container.Began
Fires with the activator each time an input begins.
container.Ended
Fires with the activator each time an input ends.
container.Changed
Fires with (active, activator, ...) when the active state flips.
container.Active
True while the input is active.
container:SetGameProcessedFilter(state)
Filters by the engine's gameProcessed flag. Pass true to fire only when the input was game processed, false to fire only when it was not, or nil to fire either way.
container:Destroy()
Disconnects the container and its signals. InputController:Unbind calls this for you.
Package Details
Install command (Click to copy)
Version
2.0.1
License
MIT
Safe for commercial use
Automated license review — not legal advice.
