Documentation ¶
Overview ¶
Package terminput provides terminal keyboard input for interactive command-line tools.
Note that this package does not enable raw mode, use github.com/pkg/term or similar.
Index ¶
Constants ¶
const ( KeyBackspace = KeyBS KeyTab = KeyTAB KeyEscape = KeyESC KeyEnter = KeyCR )
Aliases
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key rune
Key represents the key pressed.
const ( KeyNUL Key = iota KeySOH KeySTX KeyETX KeyEOT KeyENQ KeyACK KeyBEL KeyBS KeyTAB KeyLF KeyVT KeyFF KeyCR KeySO KeySI KeyDLE KeyDC1 KeyDC2 KeyDC3 KeyDC4 KeyNAK KeySYN KeyETB KeyCAN KeyEM KeySUB KeyESC KeyFS KeyGS KeyRS KeyUS // others KeyRune KeyUp KeyDown KeyRight KeyLeft KeyInsert KeyBacktab KeyDelete KeyHome KeyEnd KeyPgUp KeyPgDn KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 )
Keys supported.
type KeyboardInput ¶
type KeyboardInput struct {
// contains filtered or unexported fields
}
KeyboardInput represents a key press.
func Read ¶
func Read(r io.Reader) (*KeyboardInput, error)
Read terminal input from the given reader.
func (*KeyboardInput) Ctrl ¶
func (k *KeyboardInput) Ctrl() bool
Ctrl returns true if ctrl was pressed.
func (*KeyboardInput) Key ¶
func (k *KeyboardInput) Key() Key
Key returns the key pressed. In the case that the key returned is KeyRune, the literal value can be accessed via Rune().
func (*KeyboardInput) Meta ¶
func (k *KeyboardInput) Meta() bool
Meta returns true if meta was pressed.
func (*KeyboardInput) Rune ¶
func (k *KeyboardInput) Rune() rune
Rune returns the rune corresponding to the key press. This value is only defined when Key() is KeyRune.
func (*KeyboardInput) Shift ¶
func (k *KeyboardInput) Shift() bool
Shift returns true if shift was pressed.
func (*KeyboardInput) String ¶
func (k *KeyboardInput) String() string
String returns a human-friendly string representing the key.