mirror of
https://github.com/robotn/gohook.git
synced 2024-11-22 19:46:49 +08:00
1.3 KiB
1.3 KiB
gohook
package main
import (
"fmt"
"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.