All posts
·Rebind

Getting Started with Rebind: Your First Hardware Macro Script

How to set up your Rebind device, attach your mouse and keyboard, and write your first Luau script — from install to a working hardware macro in about 10 minutes.

rebind devicerebind scriptrebind luagetting startedhardware macros

Rebind sits between your physical keyboard and mouse and your operating system. Every input event — every keypress, mouse movement, scroll — passes through the Rebind scripting engine running on a dedicated USB microcontroller before reaching your PC. Your scripts decide what gets through, what gets blocked, and what gets transformed.

This guide covers setup through your first working script.

What you need

  • Windows 10 or 11 (64-bit)
  • A Rebind hardware device (a Teensy 4.x with Rebind firmware, or a pre-provisioned Gen1 unit)
  • Your existing USB mouse and keyboard
  • An active Rebind license

The Teensy 4.0 costs around $30. The Rebind installer handles everything else.

Installation

  1. Download the Rebind installer from rebind.gg
  2. Run the installer — it sets up all required components automatically
  3. Plug in your Rebind hardware device
  4. Launch Rebind from the Start Menu or desktop shortcut

On first launch, Rebind detects your hardware, prompts for your license key, and opens the browser-based UI at http://localhost:19480.

Attaching your devices

Rebind captures your physical mouse and keyboard so it can intercept their input. From your PC's perspective, those devices disappear and only the Rebind hardware output device remains visible.

  1. Open the Rebind UI at http://localhost:19480
  2. Go to the Devices tab
  3. Click Auto Detect — move your mouse and press a few keys during the 5-second detection window
  4. Click Attach All

Once attached, your input flows through Rebind. Press Ctrl+Alt+K at any time to immediately stop all scripts and release all held keys — this is your kill switch.

Your first script

Scripts are written in Luau — a fast, typed variant of Lua developed by Roblox. If you've used Lua before, you already know it. If not, it's one of the shortest languages to learn.

  1. Go to the Modules tab in the Rebind UI
  2. Click New Script
  3. Paste the following:
-- rebind: name=Hello World

function OnStart()
    Log.Info("Hello from Rebind!")
end

function OnDown(key)
    Log.Info("Pressed: " .. key)
    return true
end

function OnUp(key, duration)
    Log.Info("Released: " .. key .. " (held " .. duration .. "ms)")
    return true
end
  1. Click Save, then Run
  2. Open the Logs tab — every key you press and release appears there in real time

How it works

The three functions above are hooks — the Rebind runtime calls them when events arrive from your captured devices.

  • OnStart() — runs once when the script loads
  • OnDown(key) — fires when a key or mouse button is pressed
  • OnUp(key, duration) — fires when it's released, with how long it was held in milliseconds
  • return true — pass the input through to the PC unchanged
  • return false — swallow the input; the PC never sees it

That last point is the core of everything. Block the original input, send different input instead via HID, and you have a remap. Here's CapsLock remapped to Escape:

-- rebind: name=CapsLock to Escape

function OnDown(key)
    if key == "CapsLock" then
        HID.Press("Escape")
        return false   -- block the original CapsLock
    end
    return true
end

function OnUp(key)
    if key == "CapsLock" then
        return false   -- block the release too
    end
    return true
end

Sending output with HID

The HID namespace sends keyboard and mouse output through the hardware device. Your PC sees it as real input:

HID.Press("Space")           -- tap Space
HID.Press("LCtrl+C")        -- Ctrl+C
HID.Press("LCtrl+LShift+T") -- Ctrl+Shift+T
HID.Down("W")               -- hold W down
HID.Up("W")                 -- release W
HID.Type("Hello!")           -- type a string
HID.Move(10, -5)            -- move mouse 10px right, 5px up
HID.Scroll(3)               -- scroll up 3 notches

Sequences with Run and Sleep

Anything that needs to happen over time goes inside Run(). Sleep() pauses the coroutine without blocking other input:

-- rebind: name=Sequence Demo

Bind("F9", function()
    Run(function()
        HID.Press("LCtrl+A")   -- select all
        Sleep(200)
        HID.Press("LCtrl+C")   -- copy
        Sleep(200)
        HID.Press("End")       -- move to end
        Sleep(100)
        HID.Press("LCtrl+V")   -- paste
    end)
end)

Run() launches a coroutine that executes alongside everything else. You can start multiple at once and they all run in parallel.

Targeting specific apps

Add -- rebind: process= to restrict a script to a specific application. The script activates when that process is focused and goes dormant otherwise — zero overhead when not in use:

-- rebind: name=Browser Tabs
-- rebind: process=chrome.exe
-- rebind: process=firefox.exe
-- rebind: process=msedge.exe

function OnDown(key)
    if key == "Mouse4" then
        HID.Press("LCtrl+PageUp")   -- previous tab
        return false
    end
    if key == "Mouse5" then
        HID.Press("LCtrl+PageDown") -- next tab
        return false
    end
    return true
end

You can keep dozens of targeted scripts loaded simultaneously — one for Photoshop, one for your browser, one for each game — and they coexist without interfering with each other. Only the script matching the focused window runs.

Next steps

  • Browse the marketplace for ready-made scripts — gaming, productivity, accessibility, automation — each with a generated settings panel you can customize without writing code
  • Read the full SDK documentation for every available function
  • Check the examples for complete scripts from beginner to advanced
  • Use RebindGPT to write scripts by describing what you want in plain English
Back to all posts