mirror of
https://github.com/robotn/gohook.git
synced 2024-11-24 05:13:17 +08:00
键盘事件监控, from : https://github.com/robotn/gohook.git
.github | ||
chan | ||
event | ||
examples | ||
hook | ||
test | ||
.gitignore | ||
appveyor.yml | ||
circle.yml | ||
event.go | ||
extern.go | ||
go.mod | ||
go.sum | ||
hook_test.go | ||
hook.go | ||
keycode.go | ||
LICENSE | ||
README.md | ||
tables.go |
gohook
Requirements (Linux):
Install:
With Go module support (Go 1.11+), just import:
import "github.com/robotn/gohook"
Examples:
package main
import (
"fmt"
hook "github.com/robotn/gohook"
)
func main() {
add()
low()
}
func add() {
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
fmt.Println("ctrl-shift-q")
hook.End()
})
fmt.Println("--- Please press w---")
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
fmt.Println("w")
})
s := hook.Start()
<-hook.Process(s)
}
func low() {
evChan := hook.Start()
defer hook.End()
for ev := range evChan {
fmt.Println("hook: ", ev)
}
}
Based on libuiohook.