05-05-26

Auto-Walk with Strafe and Speed Control

This Lua script for Rebind hardware input enables auto-walking with strafing support using A/D or arrow keys. It also includes a UI slider to control the movement speed, enhancing your gameplay experi

rebindlua scriptauto-walkstrafespeed controlhardware inputscript

Question

Auto-walk with strafe support

Rebind AI

luau
-- rebind: name=Auto-walk with Strafe
-- rebind: description=Hold a key to auto-walk, use arrow keys or A/D to strafe while walking

local cfg = UI.Schema({
    walk_key = UI.Keybind("Mouse4", { label = "Auto-walk Key" }),
    speed = UI.Slider(100, { min = 50, max = 200, suffix = "%", label = "Movement Speed" }),
})

local walking = false
local walkTask = nil

function OnDown(key)
    if key == cfg.walk_key then
        if not walking then
            walking = true
            walkTask = Run(function()
                HID.Down("W")
                while walking do
                    Sleep(50)
                end
                HID.Up("W")
            end)
            UI.Notify("Auto-walk ON", "info")
        end
        return false
    end
    return true
end

function OnUp(key)
    if key == cfg.walk_key then
        if walking then
            walking = false
            if walkTask then
                walkTask:Cancel()
                walkTask = nil
            end
            UI.Notify("Auto-walk OFF", "info")
        end
        return false
    end
    return true
end

function OnBlur()
    if walking then
        walking = false
        if walkTask then
            walkTask:Cancel()
            walkTask = nil
        end
        HID.Up("W")
    end
end

This script provides:

  • Auto-walk toggle: Hold the configured key (default Mouse4) to start walking forward with W
  • Strafe support: While auto-walking, you can freely use A/D or arrow keys to strafe left/right without interrupting forward movement
  • Speed control: Adjust movement speed via the UI slider (50-200%)
  • Clean exit: Releases W and cancels the walk task when you release the key or switch windows

The script works by holding W continuously in a background coroutine. Arrow keys and A/D pass through normally, so strafing works naturally without any special handling.

Learn more