BindKey

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 09:52, 15 August 2026 by QCherry (talk | contribs) (Complete Lua function catalog)
Jump to navigation Jump to search

bindKey

Binds a keyboard or mouse key to a client-side Lua callback and consumes the corresponding game input while the binding is active.

Syntax

bool bindKey(string keyName, string keyState, function handler [, mixed arguments...])

Parameters

Name Type Required Description
keyName string yes The case-insensitive key name, for example tab, f5, mouse1 or a.
keyState string yes The transition to handle: down, up or both.
handler function yes The callback invoked as handler(keyName, keyState, ...).
arguments... mixed no Optional nil, boolean, number or string values appended to every callback invocation.

Returns

Returns true when the binding is registered, or false for an invalid key, invalid state, duplicate binding or exhausted resource limit.

Examples

Show a scoreboard while Tab is held:

local function handleScoreboard(keyName, keyState)
    if keyState == "down" then
        guiShow(scoreboard)
        guiSetInputActive(scoreboard, true)
    else
        guiSetInputActive(scoreboard, false)
        guiHide(scoreboard)
    end
end

bindKey("tab", "both", handleScoreboard)

Notes

  • Available only in client-side resource scripts.
  • Bindings are owned by the creating resource and are removed automatically when that resource stops.
  • A new binding does not begin while another RmlUi document owns text or pointer input. A key-up transition belonging to an active binding is still delivered so the UI can close safely.
  • The client runtime polls keys only while the G1R window is focused. It does not install a global keyboard hook and does not use Unreal ProcessEvent.
  • Each resource may register at most 128 bindings.