Clone this repo:
  1. 72ed86c Merge pull request #40 from zetamatta/master by mattn · 5 months ago master
  2. 064ebac Fix: the first key after terminal-window activated was input twice. by HAYAMA_Kaoru · 5 months ago
  3. 6cb398a Merge pull request #39 from srlehn/tinygo_noosfilewritestring by mattn · 7 months ago
  4. 5b7161e use var for \n byte slice by Simon Lehn · 7 months ago
  5. 2022806 use runes instead of casting strings to []byte by Simon Lehn · 7 months ago

go-tty

Simple tty utility

Usage

tty, err := tty.Open()
if err != nil {
	log.Fatal(err)
}
defer tty.Close()

for {
	r, err := tty.ReadRune()
	if err != nil {
		log.Fatal(err)
	}
	// handle key event
}

if you are on windows and want to display ANSI colors, use go-colorable.

tty, err := tty.Open()
if err != nil {
	log.Fatal(err)
}
defer tty.Close()

out := colorable.NewColorable(tty.Output())

fmt.Fprintln(out, "\x1b[2J")

Installation

$ go get github.com/mattn/go-tty

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)