gsh/input/key

The key module defines the domain model for terminal input events.

When the TTY operates in raw mode, user keystrokes—ranging from single UTF-8 graphemes to multi-byte ANSI escape sequences (e.g., arrow keys, word navigation)— are captured as raw byte streams. This module provides an algebraic data type to abstract low-level TTY sequences into structured events for the editor.

Types

Represents a parsed keystroke or control sequence captured from raw terminal input.

pub type Key {
  Character(String)
  Enter
  Backspace
  Tab
  ArrowUp
  ArrowDown
  ArrowLeft
  ArrowRight
  CtrlL
  End
  Home
  CtrlLeft
  CtrlRight
  Unknown
}

Constructors

  • Character(String)

    A printable UTF-8 character grapheme (e.g., "a", "Z", "5", " ").

  • Enter

    The Return/Enter key, signaling prompt submission or line insertion.

  • Backspace

    The Backspace key, used to remove the character grapheme preceding the cursor.

  • Tab

    The Tab key, used to trigger predictive autocompletion and candidate grid menus.

  • ArrowUp

    The Up Arrow key, used for upward 2D cursor traversal or history retrieval.

  • ArrowDown

    The Down Arrow key, used for downward 2D cursor traversal or history retrieval.

  • ArrowLeft

    The Left Arrow key, used to move the cursor backward by one grapheme.

  • ArrowRight

    The Right Arrow key, used to move the cursor forward by one grapheme.

  • CtrlL

    The Ctrl+L chord, triggering a screen clear while preserving active buffer state.

  • End

    The Home key (or Fn+Left), repositioning the cursor to the start of the current line.

  • Home

    The End key (or Fn+Right), repositioning the cursor to the end of the current line.

  • CtrlLeft

    The Ctrl+Left chord, jumping the cursor backward across word boundaries.

  • CtrlRight

    The Ctrl+Right chord, jumping the cursor forward across word boundaries.

  • Unknown

    Unrecognized or unhandled ANSI escape sequences (e.g., function keys, scroll lock).

Search Document