OSRS WASD Camera

@rebind / osrs-wasd-camerav0.1.1Public

Hold Caps Lock and steer the Old School RuneScape camera with WASD, one key for one arrow.

Files

main.luau1.2 KB

-- OSRS WASD Camera: while the layer key is held, W, A, S and D each become
-- one arrow key, a strict 1:1 remap. Release it to type in chat again.

local cfg = UI.Schema({
  layer = UI.Keybind("CapsLock", { label = "Hold to steer the camera" }),
  up = UI.Keybind("W", { label = "Camera up" }),
  left = UI.Keybind("A", { label = "Camera left" }),
  down = UI.Keybind("S", { label = "Camera down" }),
  right = UI.Keybind("D", { label = "Camera right" }),
})

-- the layer key does nothing else while this runs
Bind(cfg.layer, function() end)

local function steering()
  return Input.IsDown(cfg.layer)
end

for name, arrow in { up = "Up", left = "Left", down = "Down", right = "Right" } do
  Bind(cfg[name], {
    when = steering,
    action = function()
      HID.Down(arrow)
    end,
    release = function()
      HID.Up(arrow)
    end,
  })
end

function OnStart()
  if _REBIND.platform == "macos" and cfg.layer == "CapsLock" then
    UI.Notify(
      "On macOS, Caps Lock turns the camera keys on and off instead of being held.",
      "info"
    )
  end
end

function OnStop()
  for _, arrow in { "Up", "Left", "Down", "Right" } do
    HID.Up(arrow)
  end
end

3 files, 3.4 KB.