{"id":16788563,"url":"https://github.com/mna/zzterm","last_synced_at":"2026-05-21T07:43:49.493Z","repository":{"id":64302132,"uuid":"252196225","full_name":"mna/zzterm","owner":"mna","description":"Zero-allocation terminal input key and mouse decoder in Go (mirror).","archived":false,"fork":false,"pushed_at":"2021-07-15T20:26:32.000Z","size":52,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T10:28:09.439Z","etag":null,"topics":["mirror","terminal"],"latest_commit_sha":null,"homepage":"https://git.sr.ht/~mna/zzterm","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["mna"],"custom":["https://www.buymeacoffee.com/mna"]}},"created_at":"2020-04-01T14:19:50.000Z","updated_at":"2021-07-15T20:26:35.000Z","dependencies_parsed_at":"2023-01-15T09:45:21.607Z","dependency_job_id":null,"html_url":"https://github.com/mna/zzterm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mna%2Fzzterm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mna%2Fzzterm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mna%2Fzzterm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mna%2Fzzterm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mna","download_url":"https://codeload.github.com/mna/zzterm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955715,"owners_count":20374372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mirror","terminal"],"created_at":"2024-10-13T08:18:18.283Z","updated_at":"2026-05-21T07:43:49.436Z","avatar_url":"https://github.com/mna.png","language":"Go","funding_links":["https://github.com/sponsors/mna","https://www.buymeacoffee.com/mna"],"categories":[],"sub_categories":[],"readme":"# zzterm [![builds.sr.ht status](https://builds.sr.ht/~mna/zzterm.svg)](https://builds.sr.ht/~mna/zzterm?) [![Go Reference](https://pkg.go.dev/badge/git.sr.ht/~mna/zzterm.svg)](https://pkg.go.dev/git.sr.ht/~mna/zzterm)\n\nPackage zzterm efficiently reads and decodes terminal input keys and mouse events\nwithout any memory allocation. It is intended to be used with a terminal set in\nraw mode as its `io.Reader`. See the [package documentation][godoc] for details,\nAPI reference and usage example.\n\nYou can also check out [zztermtest][zztt] for more usage examples and how to\nefficiently print output to an `io.Writer` (with a zero-allocation \"echo\"\nprogram example).\n\n* Canonical repository: https://git.sr.ht/~mna/zzterm\n* Issues: https://todo.sr.ht/~mna/zzterm\n* Builds: https://builds.sr.ht/~mna/zzterm\n\nNote that at the moment, zzterm is only tested on macOS and linux. Mouse support\nis through the Xterm X11 mouse protocol with SGR enabled, the terminal has to\nsupport that mode for mouse (and focus) key events to be emitted.\n\n## See Also\n\nSimilar Go packages:\n\n* [tj/go-terminput](https://github.com/tj/go-terminput): similar small scope\nwith a focus on input key decoding, no mouse support.\n* [gdamore/tcell](https://github.com/gdamore/tcell): larger scope, handles\noutput too, colors, raw mode, etc.\n* [nsf/termbox-go](https://github.com/nsf/termbox-go): larger scope like tcell.\n\n## Benchmarks\n\nThe input processing is typically in the hot path of a terminal application. Zzterm\nis quite fast and does not allocate - not when decoding standard keys, not when\ndecoding escape sequences, neither when decoding mouse events.\n\n```\nbenchmark                                    iter     time/iter   bytes alloc        allocs\n---------                                    ----     ---------   -----------        ------\nBenchmarkInput_ReadKey/a-4               61804756   18.40 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/B-4               66716232   17.90 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/1-4               62950432   18.60 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/\\x00-4            65492827   18.20 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/ø-4               60368734   19.90 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/👪-4              57783043   20.60 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/平-4              57067489   20.80 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/\\x1b[B-4          26063134   45.90 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/\\x1b[1;2C-4       26355364   45.40 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/\\x1b[I-4          26530273   44.40 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey/\\x1b[\u003c35;1;2M-4   21740397   55.30 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey_Bytes-4           49141444   24.40 ns/op        0 B/op   0 allocs/op\nBenchmarkInput_ReadKey_Mouse-4           19961526   60.70 ns/op        0 B/op   0 allocs/op\n```\n\n## License\n\nThe [BSD 3-Clause license][bsd].\n\n[bsd]: http://opensource.org/licenses/BSD-3-Clause\n[godoc]: https://pkg.go.dev/git.sr.ht/~mna/zzterm\n[pgd]: https://pkg.go.dev/git.sr.ht/~mna/zzterm\n[zztt]: https://git.sr.ht/~mna/zztermtest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmna%2Fzzterm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmna%2Fzzterm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmna%2Fzzterm/lists"}