LED is a lightweight text editor written using Go.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
306 B

5 years ago
  1. package utils
  2. import (
  3. "github.com/pkg/term"
  4. )
  5. // Getch simply listens for input from stdin
  6. func Getch() []byte {
  7. t, _ := term.Open("/dev/tty")
  8. term.RawMode(t)
  9. bytes := make([]byte, 3)
  10. numRead, err := t.Read(bytes)
  11. t.Restore()
  12. t.Close()
  13. if err != nil {
  14. return nil
  15. }
  16. return bytes[0:numRead]
  17. }