Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tj/go-terminput
Package terminput provides terminal keyboard input for interactive command-line tools.
https://github.com/tj/go-terminput
command-line go golang input keyboard terminal
Last synced: 2 months ago
JSON representation
Package terminput provides terminal keyboard input for interactive command-line tools.
- Host: GitHub
- URL: https://github.com/tj/go-terminput
- Owner: tj
- License: mit
- Created: 2019-09-30T13:21:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-15T05:50:13.000Z (about 4 years ago)
- Last Synced: 2024-10-26T09:38:13.309Z (3 months ago)
- Topics: command-line, go, golang, input, keyboard, terminal
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 117
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Go Terminput
Package terminput provides terminal keyboard input for interactive command-line tools.
## Example
```go
package mainimport (
"fmt"
"log""github.com/pkg/term"
"github.com/tj/go-terminput"
)func main() {
t, err := term.Open("/dev/tty")
if err != nil {
log.Fatalf("error: %s\n", err)
}t.SetRaw()
defer t.Restore()fmt.Printf("Type something, use 'q' to exit.\r\n")
for {
e, err := terminput.Read(t)
if err != nil {
log.Fatalf("error: %s\n", err)
}if e.Key() == terminput.KeyEscape || e.Rune() == 'q' {
break
}fmt.Printf("%s — shift=%v ctrl=%v alt=%v meta=%v\r\n", e.String(), e.Shift(), e.Ctrl(), e.Alt(), e.Meta())
}
}
```---
[![GoDoc](https://godoc.org/github.com/tj/go-terminput?status.svg)](https://godoc.org/github.com/tj/go-terminput)
![](https://img.shields.io/badge/license-MIT-blue.svg)
![](https://img.shields.io/badge/status-stable-green.svg)## Sponsors
This project is sponsored by [CTO.ai](https://cto.ai/), making it easy for development teams to create and share workflow automations without leaving the command line.
[![](https://apex-software.imgix.net/github/sponsors/cto.png)](https://cto.ai/)
And my [GitHub sponsors](https://github.com/sponsors/tj):
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/0)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/1)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/2)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/3)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/4)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/5)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/6)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/7)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/8)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/9)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/10)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/11)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/12)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/13)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/14)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/15)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/16)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/17)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/18)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/19)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/20)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/21)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/22)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/23)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/24)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/25)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/26)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/27)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/28)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/29)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/30)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/31)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/32)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/33)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/34)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/35)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/36)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/37)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/38)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/39)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/40)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/41)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/42)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/43)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/44)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/45)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/46)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/47)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/48)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/49)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/50)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/51)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/52)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/53)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/54)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/55)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/56)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/57)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/58)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/59)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/60)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/61)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/62)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/63)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/64)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/65)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/66)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/67)
[](https://sponsors-api-u2fftug6kq-uc.a.run.app/sponsor/profile/68)