Read a character from standard input in Go (without pressing Enter)

前端 未结 6 1699
甜味超标
甜味超标 2020-12-08 20:29

I want to my app shows:

press any key to exit ...

And when I pressed any key, it exits.

How can I achieve this?

6条回答
  •  再見小時候
    2020-12-08 20:47

    termbox-go is a light-weight Go-native package which offers some rudimentary terminal control. Including the ability to get input in raw mode (read one character at a time without the default line-buffered behaviour).

    It also has fairly ok compatibility across different systems.

    And keyboard extends termbox-go to give some additional keyboard functionality like multi-key shortcuts and sequences.

提交回复
热议问题