Add delete key code

The ascii code of the delete key of macOS is 127.
1 file changed
tree: a4fc609c193e8569c21bb0c21e35a8ada66650fa
  1. example/
  2. .travis.yml
  3. README.md
  4. tty.go
  5. tty_bsd.go
  6. tty_linux.go
  7. tty_plan9.go
  8. tty_unix.go
  9. tty_windows.go
README.md

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

TOOD

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)