05-03-26
Auto Sprint with Hold Time
This Lua script for Rebind hardware input enables auto-sprinting by holding the W key for a configurable duration. It uses System.Time() and Input.IsDown() to manage the sprint state and HID.Down/Up t
rebindlua scriptauto sprinthardware inputscriptsprintlua
Question
Auto-sprint when W is held for 1 second
Rebind AI
luau
-- rebind: name=Auto Sprint
local cfg = UI.Schema({
enabled = UI.Toggle(true, { label = "Enable" }),
delay = UI.Slider(1000, { min = 500, max = 2000, suffix = "ms", label = "Hold Time" }),
})
local wPressTime = nil
local sprintActive = false
function OnDown(key)
if not cfg.enabled then return true end
if key == "W" then
wPressTime = System.Time()
sprintActive = false
end
return true
end
function OnUp(key)
if key == "W" then
if sprintActive then
HID.Up("LCtrl")
sprintActive = false
end
wPressTime = nil
end
return true
end
function OnTick()
if not cfg.enabled or not wPressTime or sprintActive then return end
if System.Time() - wPressTime >= cfg.delay and Input.IsDown("W") then
HID.Down("LCtrl")
sprintActive = true
end
end
function OnBlur()
if sprintActive then
HID.Up("LCtrl")
sprintActive = false
end
wPressTime = nil
endThis script automatically presses and holds Ctrl (Sprint) when W has been held for the configured duration. It works by:
- Recording the time when W is pressed
- Checking each tick if W is still held and the delay has elapsed
- Engaging sprint (holding Ctrl) only once
- Releasing sprint when W is released
- Cleaning up in
OnBlurif the window loses focus
The delay is configurable from 500ms to 2000ms via the UI.
Learn more