Skip to main content
Rebind 3.9.0 added the rb global, the surface the 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. The globals move onto rb: 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:

Reshaped calls

Calls whose optional arguments were positional take one options table in rb: Net.Delete and Net.Head reshape like Net.Get; Net.Put and Net.Patch like Net.Post.

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:
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. 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.
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: 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: