05-19-26

Quickstop Counter-Strafe with Bunnyhop Support

This Lua script for hardware input provides quickstop counter-strafing on movement key release, with added support for bunnyhopping. Configure the counter-strafe duration and jump window.

rebindlua scriptquickstopcounter-strafebunnyhopscripthardware input

Question

Create a script that implements a "quickstop" feature, automatically counter-strafing when a movement key is released.

Rebind AI

I need to clarify a few things before writing the script:

  1. Which movement keys do you want quickstop on? Just forward (W), or all four directions (W, A, S, D)?
  2. Counter-strafe behavior: When you release a key, should it press the opposite key for a short time? For example:
    • Release W → press S briefly?
    • Release A → press D briefly?
  3. How long should the counter-strafe hold last? (e.g., 50ms, 100ms, etc.)
  4. Overlap handling: If you're holding W+A and release W, should it only counter with S, or should it also consider that A is still held?

For now, I'll write a straightforward version: opposite key counter-strafe on release, configurable duration, with SOCD (simultaneous opposite key) awareness so it doesn't fight your inputs.

lua
-- rebind: min_sdk=0.1.0 tick_rate=8000
-- rebind: name=Quickstop Counter-Strafe

local cfg = UI.Schema({
    enabled = UI.Toggle(true, { label = "Enable Quickstop" }),
    duration = UI.Slider(50, { min = 10, max = 200, suffix = "ms", label = "Counter-Strafe Duration" }),
})

local OPPOSITE = {
    W = "S",
    S = "W",
    A = "D",
    D = "A",
}

function OnUp(key, durationMs)
    if not cfg.enabled or not OPPOSITE[key] then
        return true
    end

    local opposite = OPPOSITE[key]

    -- don't counter-strafe if the opposite key is already held
    if Input.IsDown(opposite) then
        return true
    end

    -- counter-strafe with a brief hold
    Run(function()
        HID.Down(opposite)
        Sleep(cfg.duration)
        HID.Up(opposite)
    end)

    return true
end

How it works:

  • When you release a movement key (W, A, S, D), the script checks if the opposite key is already held
  • If the opposite is NOT held, it taps the opposite key for the configured duration (default 50ms)
  • If the opposite IS held, it does nothing (respects your input)
  • The script always passes the key through (return true)

Example: You're holding W forward. You release W. The script taps S for 50ms, creating the counter-strafe brake effect.

To adjust behavior:

  • Increase duration for a longer/more aggressive counter-strafe
  • Change OPPOSITE table if you want different pairs (though W↔S and A↔D are standard)
  • Remove return true and change to return false if you want to block the original key release

Does this match what you're looking for, or do you need different behavior?

Question

Modify the script so that it allows for bunnyhopping. Specifically, disable counter-strafing when the scroll wheel or space bar is pressed.

Rebind AI

lua
-- rebind: min_sdk=0.1.0 tick_rate=8000
-- rebind: name=Quickstop Counter-Strafe

local cfg = UI.Schema({
    enabled = UI.Toggle(true, { label = "Enable Quickstop" }),
    duration = UI.Slider(50, { min = 10, max = 200, suffix = "ms", label = "Counter-Strafe Duration" }),
})

local OPPOSITE = {
    W = "S",
    S = "W",
    A = "D",
    D = "A",
}

local lastJumpTime = 0
local JUMP_WINDOW = 100 -- ms after jump to allow bhop

function OnUp(key, durationMs)
    if not cfg.enabled or not OPPOSITE[key] then
        return true
    end

    local opposite = OPPOSITE[key]

    -- don't counter-strafe if the opposite key is already held
    if Input.IsDown(opposite) then
        return true
    end

    -- don't counter-strafe if we recently jumped (within JUMP_WINDOW)
    if System.Time() - lastJumpTime < JUMP_WINDOW then
        return true
    end

    -- counter-strafe with a brief hold
    Run(function()
        HID.Down(opposite)
        Sleep(cfg.duration)
        HID.Up(opposite)
    end)

    return true
end

function OnScroll(delta)
    lastJumpTime = System.Time()
    return true
end

function OnDown(key)
    if key == "Space" then
        lastJumpTime = System.Time()
    end
    return true
end

What changed:

  • Added lastJumpTime tracking and a JUMP_WINDOW of 100ms
  • When you scroll wheel or press Space, the script marks a jump and disables counter-strafe for the next 100ms
  • This lets you bhop freely — movement key releases during that window won't trigger counter-strafe
  • After the jump window closes, quickstop resumes

Tweak JUMP_WINDOW if 100ms feels too long or short for your bhop rhythm.