InputRegistry - Powerful User Input Handling Framework

InputRegistry (v1.3)

Creator Store | Download File (8.9 KB) | Donate :3


Input Registry is a lightweight framework module that makes handling user input much easier. I will personally maintain this module, so suggestions, bug reports are more than welcomed.

Features

  • Lightweight. Fully event-based
  • Fully type-checked and commented. Easy coding!
  • Unlimited input methods, even on same device
  • Most methods are chainable
  • Easy input-disabling
  • Built-in trigger types
  • Runtime binding modifications
  • Supports detection of Modifier keys

Interested? Let’s dive in.

Example - Basic Sprinting System

First, get a ScreenGui that holds the Sprinting button for mobiles ready.
NOTE: Disable Shift Lock first otherwise you will not be able to shift-to-sprint.

local RF = game:GetService("ReplicatedFirst")
local Players = game:GetService("Players")

local InputRegistry = require(RF:WaitForChild("InputRegistry"))

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-->> Assuming you have these ready..
local sprintGui = playerGui:WaitForChild("SprintGui")
local sprintBtn = sprintGui:WaitForChild("SprintBtn")

-->> Register a Registry to handle inputs
local sprintRegistry = InputRegistry.Register("Sprint")
sprintRegistry:AddInput(Enum.KeyCode.LeftShift, "Hold") 
sprintRegistry:AddInput(Enum.KeyCode.ButtonB, "Toggle") 
sprintRegistry:AddInput(sprintBtn, "Toggle")

sprintRegistry.StatusChanged:Connect(function(status)
	if not player.Character then return end
	
	local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
	-->> Status is either "Active" or "Idle"
	if status == "Active" then
		humanoid.WalkSpeed = 24
	else
		humanoid.WalkSpeed = 16
	end
end)
Internal Types

Types

-->> ALL OF THESE ARE USED INTERNALLY AND ARE NOT ACCESSIBLE FOR EXTERNAL USE!!!

type InputType = "Keybind" | "UIButton"
type InputInst = Enum.KeyCode | GuiButton
type TriggerType = "Click" | "Hold" | "Toggle"
Use Cases

Method Chaining

return InputRegistry.Register("MyRegistry")
    :AddInput(Enum.KeyCode.LeftShift, "Hold") 
    :AddInput(Enum.KeyCode.ButtonB, "Toggle")
    :AddInput(someKindOfButton, "Toggle")

Runtime Binds Editing

local registry = InputRegistry.Register("registry")
task.wait(1)
-->> Yes, just that simple!
registry:AddInput(Enum.KeyCode.LeftShift, "Hold") 

Custom Keybinds Integration

local function modifyKeybind(keybind: Enum.Keycode)
    registry:RemoveInput(keybind)
    registry:AddInput(ketbind, "Click")
end

-->> This is if you want to modify keybind to LeftShift
modifyKeybind(Enum.Keycode.LeftShift)

Detecting Modifier Keys

registry.InputStarted:Connect(function(inputInstance, modifierKeys: {Enum.Modifierkey})
    for i, v in modifierKeys do
        print(`Modifier key {v} is pressed!`)
    end
end)

Adding Inputs Exclusive to Certain PerferredInputs

registry:AddExclusiveInput(Enum.PreferredInput.Touch, Path.To.Button, "Click")

Halting Input Detection

-->> Alternative option: Registry.Status ("Active | "Idle")
-->> Input events will not be fired when a character's PlayingAnim attribute is set to true
registry:SetChecker(function()
    if character:GetAttribute("PlayingAnim") then
        return false
    end
    return true
end)
License
MIT License

Copyright [2026+] [The Creator]

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in the 
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Wait, before you go..

Rate this module from 1 to 5! (5 = highest)
  • 1
  • 2
  • 3
  • 4
  • 5
0 voters
Will you use InputRegistry?
  • Yes, this looks useful!
  • I don’t think I need it yet.
  • It isn’t that good to be used.
0 voters

Suggestions, bug reports, and questions are always welcomed. Happy coding!

Credits

7 Likes

Update v1.1

  • Registry.StatusChanged no longer fires when the status does not change.

Update v1.1.1

  • Fixed critical Input detection bug for keybinds

this library looks promising, Ill probably take a look at how this library is structured from the inside

1 Like

so i noticed not good latency in my tests, i used programm on C which sets hook on keyboard and prints time:

Code in C:

#include <windows.h>
#include <stdio.h>

HHOOK keyboardHook = NULL;

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
    if (nCode == HC_ACTION) {
        if (wParam == WM_KEYDOWN) {
            KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;

            SYSTEMTIME localTime;
            GetLocalTime(&localTime);

            printf("%02d:%02d:%02d.%03d\n",
                localTime.wHour,
                localTime.wMinute,
                localTime.wSecond,
                localTime.wMilliseconds);

        }
    }
    return CallNextHookEx(keyboardHook, nCode, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow) {

    AllocConsole();
    freopen("CONOUT$", "w", stdout);

    keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc,
        hInstance, 0);

    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    UnhookWindowsHookEx(keyboardHook);
    return 0;
}

also i compiled this code with GCC

now i created script in luau with InputRegistry and raw UIS and here my results vs C:

--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InputRegistry = require(ReplicatedStorage.InputRegistry)

local UserInputService = game:GetService("UserInputService")

local X = InputRegistry.Register("Sprint")
X:AddInput(Enum.KeyCode.X, "Click") 

X.StatusChanged:Connect(function(status)
	if status == "Active" then
		print("\n") -- in output we can see time when it prints
	end
end)

UserInputService.InputBegan:Connect(function(input: InputObject, GPE: boolean)
	if GPE then return end
	if input.KeyCode == Enum.KeyCode.X then
		print("\n")  -- in output we can see time when it prints
	end
end)
Input Registry UIS
Difference vs C: 4ms Difference vs C: 3ms
Difference vs C: 5ms Difference vs C: 5ms
Difference vs C: 3ms Difference vs C: 3ms
Difference vs C: 4ms Difference vs C: 3ms
Difference vs C: 10 ms Differnce vs C: 9ms
Diffrence vs C: 8ms Diffrence vs C: 8ms
Difference vs C: 4ms Difference vs C: 3ms
Difference vs C: 4ms Difference vs C: 4ms
Difference vs C: 4ms Difference vs C: 3ms
Difference vs C: 7ms Difference vs C: 7ms
AVG: 5.3ms AVG: 4.8ms

overall its a not bad module but this module is most likely not suitable for FPS games

1 Like

The module is essentially a wrapper of UIS so yeah it definitely takes slightly more time to process things compared to raw UIS

If maximum performance is needed then yeah it might not be suitable

Also you are supposed to place the module under ReplicatedFirst because it shouldn’t be needed on the server side

i just putted this module in ReplicatedStorage cuz i I just got used to putting everything there, but this module requires on LocalScript in StarterCharacterScripts

1 Like

Update v1.2

  • Holding no longer halts if one of multiple being-pressed keybinds was stopped being pressed
  • Fixed issues with UIButtons holding

Update V1.3

  • Added a Registry.LastInputTimestamp which stores the timestamp of when the last input is made and processed.
  • Added a InputRegistry.PreferredInput which is equivalent to UserInputService.PreferredInput.
  • Fixed memory leaks.

Release: InputRegistry.rbxm (8.9 KB)

Very cool, I think the typing could use a bit of work but can’t wait for future updates. It’d be awesome if you’d be able to add support for feeding IAS instances as parameters instead of just Keycodes, just an idea for flexibility and ease.

1 Like

so what you mean is allowing more custom status types other than just Active or Idle? correct me if Im wrong