Skip to main content

Keybindings

The Pi-TUI keybinding system provides configurable keyboard shortcuts for editor actions with support for multi-key bindings.

Editor Actions

Editor actions that can be bound to keys:

KeyId Type

Key identifiers support modifiers and special keys:

Supported Modifiers

  • ctrl+ - Control key
  • alt+ - Alt/Option key
  • shift+ - Shift key
  • Combine multiple: ctrl+alt+x, shift+ctrl+z

Special Keys

  • enter, escape, tab, backspace, delete
  • up, down, left, right
  • home, end, pageUp, pageDown
  • f1 through f12

EditorKeybindingsManager

Manages keybindings for editor actions.

Constructor

Creates a new keybindings manager with optional configuration.
EditorKeybindingsConfig
Optional keybinding overrides. Unspecified actions use defaults.

Methods

matches()

Checks if input data matches a specific action.
string
required
Raw input data from terminal
EditorAction
required
Action to check against

getKeys()

Gets all keys bound to an action.
EditorAction
required
Action to query

setConfig()

Updates keybinding configuration.
EditorKeybindingsConfig
required
New configuration. Merges with defaults.

Configuration

EditorKeybindingsConfig

Configuration object mapping actions to key identifiers.
Actions can bind to:
  • Single key: { submit: 'enter' }
  • Multiple keys: { submit: ['enter', 'ctrl+s'] }

Default Keybindings

Global Instance

Convenience functions for a global keybindings instance:

Example

Key Matching

Low-level key matching functions:

matchesKey()

Checks if raw input data matches a key identifier.
string
required
Raw input data from terminal
KeyId
required
Key identifier to match

isKeyRelease()

Checks if input data is a key release event (Kitty protocol).
string
required
Raw input data from terminal

Usage in Components

Use the keybindings manager in component input handlers:

Custom Keybinding Schemes

Create custom keybinding schemes for different workflows: