key

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package key is the keyboard input the splash acts on: characters already mapped by the console's keymap, and the few keys that edit or answer a prompt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder turns bytes read from a terminal in non-canonical mode into keys, keeping a multibyte character split across reads until it is whole. The bytes it keeps or joins may be part of a password, so it zeroes them once decoded, and Forget zeroes what it still keeps.

func (*Decoder) Decode

func (d *Decoder) Decode(keys []Key, b []byte) []Key

Decode appends the keys in one read's bytes to keys. An escape byte alone at the end of a read is the Escape key; one followed by '[' or 'O' starts a terminal escape sequence, such as an arrow key's, which is dropped. Other control characters and invalid UTF-8 are dropped.

func (*Decoder) Forget

func (d *Decoder) Forget()

Forget zeroes and drops the start of a character still waiting for the rest of its bytes.

type Key

type Key struct {
	Kind Kind
	Rune rune
}

Key is one key press.

type Kind

type Kind uint8

Kind is what a key does.

const (
	// Char types a character.
	Char Kind = iota
	// Enter answers a prompt.
	Enter
	// Backspace deletes the last character.
	Backspace
	// Escape toggles the boot messages.
	Escape
	// Interrupt is Ctrl-C or Ctrl-D, which abandon a prompt.
	Interrupt
)

The key kinds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL