Skip to content

Keybinds (function list)

Status: Implemented (API 1.24). Generated from client/clight/idl/clight_api.json by tools/docs/gen_api_reference.py; do not edit by hand. 4 functions, the newest from API 1.4.

Explanations and examples: Input and keybinds. Every function of the keybind module is listed here in table order. The details of each function follow the table, in the same order. Side: where the function works (server, client, both). Context: the thread it may be called on (Conventions). Since: the API version that added it.

C function Lua Side Context Since
cl_keybind_register cl.keybind.register client MAIN 1.0
cl_keybind_consume_click cl.keybind.consume_click client TICK 1.0
cl_keybind_is_down cl.keybind.is_down client ANY 1.0
cl_keybind_key cl.keybind.key client ANY 1.4

cl_keybind_register

cl_result cl_keybind_register(const cl_keybind_desc* desc, cl_keybind* out);
  • Side: client. Context: MAIN (startup (main thread)). Since: API 1.0.
  • Lua: cl.keybind.register
  • C++: (C only)
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_keybind_consume_click

bool cl_keybind_consume_click(cl_keybind k);
  • Side: client. Context: TICK (tick thread). Since: API 1.0.
  • Lua: cl.keybind.consume_click, keybind:consume_click(...)
  • C++: Keybind::consume_click() → bool; clight::keybind::consume_click(Keybind k) → bool

cl_keybind_is_down

bool cl_keybind_is_down(cl_keybind k);
  • Side: client. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.keybind.is_down, keybind:is_down(...)
  • C++: Keybind::is_down() → bool; clight::keybind::is_down(Keybind k) → bool

cl_keybind_key

cl_result cl_keybind_key(cl_keybind k, char* buf, size_t cap, size_t* out_len);

The key the player bound it to (“key.keyboard.r”, “key.mouse.4”, “key.keyboard.unknown” when unbound).

  • Side: client. Context: ANY (any thread). Since: API 1.4.
  • Lua: cl.keybind.key, keybind:key(...)
  • C++: Keybind::key() → Expected<std::string>; clight::keybind::key(Keybind k) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.