gleamtea/key

Keyboard events.

beamtea’s beamtea_key module decodes raw terminal bytes into these key events. Each variant here maps to the exact Erlang term beamtea produces, so a {key, Key} message from the runtime pattern-matches straight onto gleamtea.Key(...) with one of the values below:

Types

A decoded keypress.

pub type Key {
  Up
  Down
  Left
  Right
  Home
  End
  PageUp
  PageDown
  Insert
  Delete
  Enter
  Tab
  BackTab
  Backspace
  Esc
  Ctrl(Int)
  Char(Int)
}

Constructors

  • Up
  • Down
  • Left
  • Right
  • Home
  • End
  • PageUp
  • PageDown
  • Insert
  • Delete
  • Enter
  • Tab
  • BackTab
  • Backspace
  • Esc
  • Ctrl(Int)

    A Ctrl-combination, e.g. Ctrl-C is Ctrl(99) (99 = c).

  • Char(Int)

    A printable character as a Unicode code point, e.g. Char(97) = a.

Values

pub fn to_string(k: Key) -> String

Render a Char or Ctrl code point as its UTF-8 string, e.g. to_string(Char(97)) is "a". Named keys render to their lowercase name.

Search Document