Keybind
Keyboard binding registration, storage, and execution system for the Lilia framework.
Overview
lia.keybind.add(k, d, desc, cb)
Purpose
Register a keybind action with callbacks and optional metadata.
When Called
During initialization to expose actions to the keybind system/UI.
Parameters
string|number k Key code or key name (or actionName when using table config form).
string|table d Action name or config table when first arg is action name.
string desc optional Description when using legacy signature.
table cb optional Callback table {onPress, onRelease, shouldRun, serverOnly}.
Example Usage
-- Table-based registration with shouldRun and serverOnly.
lia.keybind.add("toggleMap", {
keyBind = KEY_M,
desc = "Open the world map",
serverOnly = false,
shouldRun = function(client) return client:Alive() end,
onPress = function(client)
if IsValid(client.mapPanel) then
client.mapPanel:Close()
client.mapPanel = nil
else
client.mapPanel = vgui.Create("liaWorldMap")
end
end
})
lia.keybind.getDisplayDescription(action)
Purpose
Retrieve the localized description for a registered keybind action.
When Called
When populating tooltips or description labels in the keybind configuration UI.
Parameters
string action The action name to look up.
Returns
string Localized description string, or an empty string if the action does not exist.
Example Usage
local desc = lia.keybind.getDisplayDescription("openInventory")
print("Keybind description:", desc)
lia.keybind.getDisplayCategory(action)
Purpose
Retrieve the localized category for a registered keybind action.
When Called
When building the keybind UI to group actions under category headers.
Parameters
string action The action name to look up.
Returns
string Localized category name, or "misc" as the default fallback.
Example Usage
local cat = lia.keybind.getDisplayCategory("openInventory")
print("Keybind category:", cat)