BindKey: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Complete Lua function catalog
Document expanded scripting capacities and complete audited limits for 0.1.3 BUILD81
 
Line 1: Line 1:
<!-- This page is generated automatically from the function definition: bindKey. -->
= bindKey =
= bindKey =
Binds a keyboard or mouse key to a client-side Lua callback and consumes the corresponding game input while the binding is active.
Binds a keyboard or mouse key to a client-side Lua callback and consumes the corresponding game input while the binding is active.
Line 45: Line 44:
* 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.
* 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.
* 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.
* Each resource may register at most 1024 bindings.
* Expanded limits apply from update 0.1.3 BUILD81. See [[Scripting limits]]; earlier 0.1.3 binaries retain their old limits.


[[Category:Lua Functions]]
[[Category:Lua Functions]]
[[Category:Client Functions]]
[[Category:Client Functions]]
[[Category:Input Functions]]
[[Category:Input Functions]]

Latest revision as of 11:51, 12 September 2026

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 1024 bindings.
  • Expanded limits apply from update 0.1.3 BUILD81. See Scripting limits; earlier 0.1.3 binaries retain their old limits.