package main import ( "bufio" "fmt" "golang.org/x/term" "os" ) func goRaw() (*term.State, error) { state, err := term.MakeRaw(int(os.Stdin.Fd())) return state, err } func main() { oldState, err := goRaw() if err != nil { panic(err) } defer term.Restore(int(os.Stdin.Fd()), oldState) reader := bufio.NewReader(os.Stdin) for { char, _, err := reader.ReadRune() if err != nil { panic(err) } switch { } if char == 'q' { fmt.Println("bye!\r") return } } }