-
class Keybinding :
Object
¶ -
__new(self:
Keybinding
, schema: {key:string
, action:string
, mode:string
, description:string
}[])¶ Constructor for the Keybinding class. Initializes the keymap and modes with a predefined schema and defaults.
- Parameters:
schema ({key:
string
, action:string
, mode:string
, description:string
}[]) – A list of predefined keybindings with their schema and defaults.
-
schema:
table
¶ Holds the schema for all modes, including “default”
-
keymap:
table
¶ Stores modifications
-
set(self:
Keybinding
, key:string
, action:string
, mode:string
|nil
)¶ Sets or updates a keybinding, validating it exists in the schema.
- Parameters:
key (
string
) – The key to bind.action (
string
) – The new action to associate with the key.mode (
string
|nil
) – An optional mode for the binding (defaults to “default”).
-
keypressed(self:
Keybinding
, key:string
, mode:string
|nil
)string
|nil
¶ Handles key press events and retrieves the associated action if a binding exists. Falls back to the schema if no modification is found.
- Parameters:
key (
string
) – The key that was pressed.mode (
string
|nil
) – The mode to use for the keybinding.
- Returns:
_1 (
string
|nil
) – The action associated with the key, or nil if no binding exists.
-
clear(self:
Keybinding
, mode:string
|nil
)¶ Resets keybindings for a specific mode or all modes to their defaults.
- Parameters:
mode (
string
|nil
) – The mode to reset. If nil, resets all modes.
-
__new(self: