Raxol.Terminal.Input.SpecialKeys (Raxol v0.3.0)

View Source

Handles special key combinations and their escape sequences.

This module provides functionality for:

  • Detecting special key combinations (Ctrl, Alt, Shift, Meta)
  • Converting special keys to their corresponding escape sequences
  • Handling modifier key state
  • Supporting extended key combinations

Summary

Functions

Creates a new modifier state.

Converts a key combination to its corresponding escape sequence.

Updates the modifier state based on a key event.

Types

modifier()

@type modifier() :: :ctrl | :alt | :shift | :meta

modifier_state()

@type modifier_state() :: %{required(modifier()) => boolean()}

Functions

new_state()

Creates a new modifier state.

Examples

iex> state = SpecialKeys.new_state()
iex> state.ctrl
false

to_escape_sequence(state, key)

Converts a key combination to its corresponding escape sequence.

Examples

iex> state = SpecialKeys.new_state() |> SpecialKeys.update_state("Control", true)
iex> SpecialKeys.to_escape_sequence(state, "c")
"[99"

update_state(state, key, pressed)

Updates the modifier state based on a key event.

Examples

iex> state = SpecialKeys.new_state()
iex> state = SpecialKeys.update_state(state, "Control", true)
iex> state.ctrl
true