> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebind.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# v1 Names

> How the earlier Rebind SDK names map to rb: the naming rule, renamed and reshaped calls, events, binds, handle methods, and option keys.

Rebind 3.9.0 added the `rb` global, the surface the [SDK reference](/reference/sdk-reference)
documents. The earlier names, such as `HID.Down`, `Bind`, and `OnDown`, are the
v1 names. They keep working in every release, so existing scripts, packages, and
marketplace scripts need no change. This page maps each v1 name to its `rb`
spelling, for reading older scripts and for converting them.

## The 3.9.0 floor

A script that uses `rb` declares `min_sdk=3.9.0` or later. Older Rebind has no
`rb`, and `rebind check` refuses an `rb` call in a script that declares an
earlier `min_sdk`.

`rb` and the v1 names are the same functions, so one script can use both. A
converted script behaves the same, with the differences listed below.

## The naming rule

A v1 member becomes `rb.<namespace in lowercase>.<member in snake_case>`. Runs
of capitals count as one word.

| v1 | rb |
| - | - |
| `HID.MoveTo` | `rb.hid.move_to` |
| `Input.IsDown` | `rb.input.is_down` |
| `File.ReadJSON` | `rb.file.read_json` |
| `Net.WSConnect` | `rb.net.ws_connect` |
| `Net.UDPListen` | `rb.net.udp_listen` |
| `Hash.SHA256` | `rb.hash.sha256` |
| `Codec.Base64Decode` | `rb.codec.base64_decode` |

The globals move onto `rb`:

| v1 | rb |
| - | - |
| `Run` | `rb.run` |
| `Sleep` | `rb.sleep` |
| `After` | `rb.after` |
| `Async` | `rb.async` |
| `_REBIND` | `rb.info` |

`print`, `log`, `exit`, `die`, and `require` keep their names. `rb.log.info`,
`warn`, `error`, and `debug` accept any number of values and join them with tabs
like `print`; v1 `Log.Info` takes one string.

Key names a script passes to `rb` ignore case, so `rb.bind("f1", fn)` binds F1.
A v1 `Bind` keeps its exact matching.

## Renamed members

These 13 do not follow the rule:

| v1 | rb |
| - | - |
| `Env.AppData` | `rb.env.appdata` |
| `File.GetScriptDir` | `rb.file.script_dir` |
| `File.GetSize` | `rb.file.size` |
| `File.GetTime` | `rb.file.time` |
| `File.MkDir` | `rb.file.mkdir` |
| `File.RmDir` | `rb.file.rmdir` |
| `Input.GetActiveKeys` | `rb.input.keys` |
| `Input.GetDuration` | `rb.input.duration` |
| `Input.GetModifiers` | `rb.input.modifiers` |
| `Input.GetMousePos` | `rb.input.mouse_pos` |
| `Screen.GetPixelColor` | `rb.screen.pixel_hex` |
| `Screen.SearchForColor` | `rb.screen.search_color` |
| `Timer.CancelAll` | `rb.timer.stop_all` |

## Reshaped calls

Calls whose optional arguments were positional take one options table in `rb`:

| v1 | rb |
| - | - |
| `Net.Get(url, headers, options)` | `rb.net.get(url, { headers = ..., timeout = ... })` |
| `Net.Post(url, body, headers, options)` | `rb.net.post(url, body, { headers = ..., timeout = ... })` |
| `Macro.Play(macro, speed, mode)` | `rb.macro.play(macro, { speed = ..., mode = ... })` |
| `System.ExecDetached(cmd, args, options)` | `rb.system.exec_detached(cmd, { args = ..., cwd = ... })` |
| `Window.Move(handle, x, y, w, h)` | `rb.window.move(handle, { x = ..., y = ..., width = ..., height = ... })` |

`Net.Delete` and `Net.Head` reshape like `Net.Get`; `Net.Put` and `Net.Patch`
like `Net.Post`.

```lua theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
-- v1
Net.Get(url, nil, { timeout = 5000 })
Window.Move(hw, 0, 0, 800, 600)

-- rb
rb.net.get(url, { timeout = 5000 })
rb.window.move(hw, { x = 0, y = 0, width = 800, height = 600 })
```

## Hooks become events

A v1 hook is a global function with a fixed name. In `rb`, `rb.on` adds a
handler for the event named by the hook without `On`, in snake\_case:

| v1 hook | rb event |
| - | - |
| `OnStart`, `OnStop` | `"start"`, `"stop"` |
| `OnFocus`, `OnBlur` | `"focus"`, `"blur"` |
| `OnTick` | `"tick"` |
| `OnDown`, `OnUp`, `OnMove`, `OnScroll` | `"down"`, `"up"`, `"move"`, `"scroll"` |
| `OnInputDown`, `OnInputUp`, `OnInputMove`, `OnInputScroll` | `"input_down"`, `"input_up"`, `"input_move"`, `"input_scroll"` |
| `OnScrollH`, `OnReload`, `OnError` | `"scroll_h"`, `"reload"`, `"error"` |

```lua theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
-- v1
function OnDown(key, device)
  if key == "F1" then
    return false
  end
end

-- rb
rb.on("down", function(key, device)
  if key == "F1" then
    return false
  end
end)
```

The differences:

* A script has one v1 hook per name, and a later definition replaces an earlier
  one. `rb.on` adds a handler each time it is called, and every handler runs, in
  the order added. `rb.on` returns a handle whose `stop()` removes the handler.
* When a script defines a v1 hook and also adds handlers for the same event, the
  v1 hook runs first.
* For `down`, `up`, `move`, and `scroll`, any handler that returns `false`
  blocks the event. Returning `true` has no effect.
* `rb.on("move", ...)` raises an error in software mode.

## Bind

`rb.bind(key, fn, options)` decides whether the key is taken from its
`swallow` option, and ignores the callback's return value. A v1 `Bind` takes the
key unless its action returns a truthy value: anything but `nil` or `false`,
so a returned handle or string passes the key just as `true` does.

| v1 action | rb |
| - | - |
| returns nothing, `false`, or `nil` | `rb.bind(key, fn)` |
| always returns `true` or another truthy value | `rb.bind(key, fn, { swallow = false })` |
| returns `true` only when a check passes, with no other work on that path, in a bind with no `release` | move the check into `when`: when it returns `false`, the key falls through as before |
| returns `true` on a path that also does work, or conditionally in a bind with a `release` | a `"down"` handler that checks the key and returns `false` to block it |
| none: a table-form `Bind` without `action` | no `rb.bind`: v1 never takes that key and never runs its `release` (see below) |

`when` and a `true` return differ for `release`. A v1 action that returns
`true` lets the key through and still runs `release` when the key comes up. A
press that `when` rejects skips the bind, so `release` does not run for it. For
the same reason, a v1 table without `action` does not convert to
`rb.bind(key, nil, { release = f })`, which takes the key and runs `f`. That
table still calls its `when` on every press of the key; if `when` does work the
script relies on, move that work into an `rb.on("input_down")` observer that
checks the key.

A `down` handler makes the script capture every key, as `OnDown` does, so prefer
`when` where it fits. The handler replaces the whole bind: run what `release`
did from an `"up"` handler for the same key, and turn a `device` filter into a
check on the handler's `device` argument. A v1 bind also takes the key's release
whenever it took the press, so the `"up"` handler returns `false` for exactly
the presses the `"down"` handler blocked: record that choice per key in the
`"down"` handler, and add the `"up"` handler even when the bind had no
`release`.

```lua theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
-- v1
Bind("F10", function()
  Log.Info("F10")
  return true
end)

Bind("Mouse1", {
  when = function() return Input.IsDown("LAlt") end,
  action = function() HID.Press("A") end,
  release = function() Log.Info("released") end,
})

-- rb
rb.bind("F10", function()
  rb.log.info("F10")
end, { swallow = false })

rb.bind("Mouse1", function()
  rb.hid.press("A")
end, {
  when = function() return rb.input.is_down("LAlt") end,
  release = function() rb.log.info("released") end,
})
```

The table form's `when`, `release`, and `device` become options, and its
`action` becomes the callback, converted by the table above. `Bind.Toggle` and
`Bind.Remap` are `rb.bind.toggle` and `rb.bind.remap`.

## Handle methods

A handle method's `rb` name is the snake\_case of its v1 name, such as
`IsRunning` to `is_running` and `SendBinary` to `send_binary`, with two
exceptions:

| v1 | rb |
| - | - |
| `Cancel` (task and timer handles) | `stop` |
| `unbind` (bind handles) | `stop` |

Every handle answers to both spellings, whichever call returned it.

## Option keys

These option and field names have a snake\_case spelling. Both spellings are
read, in v1 calls and `rb` calls alike:

| v1 | rb | Where |
| - | - | - |
| `holdMs` | `hold_ms` | macro `"press"` actions |
| `charDelay` | `char_delay` | macro `"type"` actions |
| `showIf` | `show_if` | UI widget options |
| `maxLength` | `max_length` | text widget options |
| `OnConnect` | `on_connect` | `rb.net.ws_listen` handlers |
| `OnMessage` | `on_message` | `rb.net.ws_listen` and `rb.net.ws_connect` handlers |
| `OnClose` | `on_close` | `rb.net.ws_listen` and `rb.net.ws_connect` handlers |
| `OnOpen` | `on_open` | `rb.net.ws_connect` handlers |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.