hl.bind¶
- hl.bind(keys, dispatcher, opts=None)¶
Register a keybind.
Signature¶
hl.bind(keys: string, dispatcher: HL.Dispatcher | function, opts?: HL.BindOptions): HL.Keybind
Parameters¶
- keysstring
Key combination string. Modifiers come first and are separated with
+. The final non-modifier entries are interpreted as keysyms, keycodes, or special symbols.- dispatcher
HL.Dispatcheror function Dispatcher returned by
hl.dsp.*or a Lua callback function.- opts
HL.BindOptions, optional Additional keybind flags.
Key string syntax¶
Modifiers are accepted before the key:
"SUPER + Return"
"SUPER + SHIFT + Q"
"CTRL + ALT + Delete"
Accepted modifier names include SHIFT, CAPS, CTRL, CONTROL,
ALT, MOD1, MOD2, MOD3, SUPER, WIN, LOGO, MOD4,
META, and MOD5.
Special key forms:
code:<number>Bind by keycode.
mouse:<number>Bind by mouse button code. Mouse button codes below
272are rejected.switch:<name>Bind a switch input.
mouse_down,mouse_up,mouse_left,mouse_rightSpecial mouse direction symbols.
catchallCatch-all keybind. Only allowed inside submaps.
Returns¶
- keybind
HL.Keybind Runtime keybind object.
Examples¶
Bind a key to a dispatcher:
hl.bind("SUPER + Return", hl.dsp.exec_cmd("kitty"))
Bind a key to a Lua callback:
hl.bind("SUPER + P", function()
print("pressed")
end, {
description = "Print a message",
})
Bind a mouse drag:
hl.bind("SUPER + mouse:272", hl.dsp.window.drag(), {
drag = true,
})
Notes¶
Modifiers must come before non-modifier keys. Special symbols cannot be combined with other non-modifier keysyms.
See also¶
HL.BindOptionsOptions table accepted by
opts.HL.KeybindRuntime object returned by this function.
HL.DispatcherDispatcher object accepted by this function.