Keybind¶
Keybind helpers for Lilia action registration, configurable key assignment, keybind persistence, reserved-key handling, and keybind configuration UI integration.
Overview
lia.keybind.add(k, d, desc, cb)View Source
Purpose
Registers a keybind action and stores its default key, localized display metadata, press/release callbacks, optional run condition, and server-only behavior.
Realm
Shared
Parameters
string|number k The action name when using the configuration-table format, or the key code/key name when using the legacy argument format.
table|string d The keybind configuration table when k is an action name, or the action name when using the legacy argument format.
string desc optional Optional description used by the legacy argument format.
table cb optional Optional callback table used by the legacy argument format. Must include onPress and may include onRelease, shouldRun, and serverOnly.
Example Usage
lia.keybind.add("toggleExample", {
keyBind = KEY_F6,
desc = "@toggleExampleDesc",
category = "misc",
onPress = function(client)
client:notify("Pressed example keybind.")
end
})
lia.keybind.getDisplayDescription(action)View Source
Purpose
Gets the localized display description for a registered keybind action.
Realm
Shared
Parameters
string action The keybind action identifier.
Returns
string The localized action description, or an empty string if the action is not registered.
Example Usage
local description = lia.keybind.getDisplayDescription("openInventory")
lia.keybind.getDisplayCategory(action)View Source
Purpose
Gets the localized display category for a registered keybind action.
Realm
Shared
Parameters
string action The keybind action identifier.
Returns
string The localized action category, or the localized miscellaneous category when no category is set.
Example Usage
local category = lia.keybind.getDisplayCategory("openInventory")
lia.keybind.buildReservedKeys()View Source
lia.keybind.isKeyReserved(keyCode)View Source
lia.keybind.get(a, df)View Source
Purpose
Returns the selected key code for a registered keybind action, falling back to the action default or a provided fallback value.
Realm
Client
Parameters
string a The keybind action identifier.
any df Fallback value returned when the action is not registered or has no stored/default key.
Returns
any The selected key code, default key code, or fallback value.
Example Usage
local keyCode = lia.keybind.get("openInventory", KEY_NONE)
lia.keybind.save()View Source
lia.keybind.load()View Source
Hooks
Library-specific hooks documented for this library.
AddReservedKeybinds(reserved)View Source
Purpose
Allows plugins or modules to add extra reserved key codes before keybind choices are displayed.
Realm
Client
Parameters
table reserved Lookup table keyed by numeric key code. Set reserved[keyCode] to true to reserve a key.