https://github.com/hymkor/go-getch
A Library to read the console-event (keyboard-hits or screen-resize) for Go on Windows.
https://github.com/hymkor/go-getch
go windows
Last synced: 18 days ago
JSON representation
A Library to read the console-event (keyboard-hits or screen-resize) for Go on Windows.
- Host: GitHub
- URL: https://github.com/hymkor/go-getch
- Owner: hymkor
- License: bsd-3-clause
- Created: 2016-06-08T14:11:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-23T07:56:17.000Z (over 6 years ago)
- Last Synced: 2025-04-10T22:53:15.501Z (18 days ago)
- Topics: go, windows
- Language: Go
- Homepage:
- Size: 30.3 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/zetamatta/go-getch)
go-getch
=========`go-getch` is a library to read the console-event
(keyboard-hits or screen-resize),
for the programming language Go for Windows,Example
-------package main
import (
"fmt""github.com/zetamatta/go-getch"
)const COUNT = 5
func main() {
for i := 0; i < COUNT; i++ {
fmt.Printf("[%d/%d] ", i+1, COUNT)
e := getch.All()
if k := e.Key; k != nil {
fmt.Printf("\n%c %08X %08X %08X\n",
k.Rune, k.Rune, k.Scan, k.Shift)
} else if r := e.Resize; r != nil {
fmt.Printf("\nWidth=%d Height=%d\n", r.Width, r.Height)
} else {
fmt.Println("\n(unknown event)")
}
}
}- `go-getch` supports the surrogate pair of Unicode.
- `go-getch` is used in Windows CUI Shell [NYAGOS](https://github.com/zetamatta/nyagos)Types
-----type Event struct {
Focus *struct{}
Key *keyEvent // == KeyDown
KeyDown *keyEvent
KeyUp *keyEvent
Menu *struct{}
Mouse *struct{}
Resize *resizeEvent
}type keyEvent struct {
Rune rune
Scan uint16
Shift uint32
}type resizeEvent struct {
Width uint
Height uint
}Functions
---------### func All() Event
Get all keyboard events.
### func Rune() rune
Get a KeyDown event.
### func Within(msec uintptr) (Event, error)
Get all keyboard events with time-out.
### func RuneWithin(msec uintptr) (rune, error)
Get a KeyDown event with time-out.