There is a nice function in KEYBIND_STRIP that takes care of all the details:
Code:
local stripDescriptor = {
{
alignment = KEYBIND_STRIP_ALIGN_RIGHT, // or _LEFT, _CENTER
name = "Display name",
keybind = "YOUR_KEYBIND_ACTION_NAME",
callback = function(self) d("activated") end
}
}
KEYBIND_STRIP:AddKeybindButtonGroup(stripDescriptor)
-- to remove it again
-- call with exactly the same descriptor or strange things will happen
KEYBIND_STRIP:RemoveKeybindButtonGroup(stripDescriptor)
The value for keybind must be defined for the SI_KEYBINDINGS_LAYER_USER_INTERFACE_SHORTCUTS layer.
The keybind overrides any general keybind as long the as button group is displayed. For example, I assigned "J" to the binding. When the keybind is displayed, "J" triggers the callback. Otherwise, "J" opens the journal.