Clone this repo:
  1. 6774b91 Merge pull request #45 from ichizok/fix/solaris by mattn · 4 months ago master v0.0.4
  2. ba2a7ca Fix solaris support by ichizok · 4 months ago
  3. 72ed86c Merge pull request #40 from zetamatta/master by mattn · 1 year, 6 months ago
  4. 064ebac Fix: the first key after terminal-window activated was input twice. by HAYAMA_Kaoru · 1 year, 6 months ago
  5. 6cb398a Merge pull request #39 from srlehn/tinygo_noosfilewritestring by mattn · 1 year, 8 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)