Update: update examples and README.md

This commit is contained in:
vcaesar 2025-02-08 15:44:55 -08:00
parent 0d69fe6a36
commit f049036b8c
3 changed files with 19 additions and 13 deletions

View File

@ -45,7 +45,11 @@ func add() {
fmt.Println("--- Please press w---")
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
fmt.Println("w")
fmt.Println("keyDown: ", "w")
})
hook.Register(hook.KeyUp, []string{"w"}, func(e hook.Event) {
fmt.Println("keyUp: ", "w")
})
s := hook.Start()

View File

@ -6,6 +6,15 @@ import (
hook "github.com/robotn/gohook"
)
func main() {
registerEvent()
base()
add()
addMouse()
}
func registerEvent() {
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
@ -15,7 +24,11 @@ func registerEvent() {
fmt.Println("--- Please press w ---")
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
fmt.Println("w-")
fmt.Println("KeyDown: ", "w-")
})
hook.Register(hook.KeyUp, []string{"w"}, func(e hook.Event) {
fmt.Println("KeyUp: ", "w")
})
s := hook.Start()
@ -69,12 +82,3 @@ func base() {
}
}
}
func main() {
registerEvent()
base()
add()
addMouse()
}

View File

@ -118,7 +118,6 @@ func Register(when uint8, cmds []string, cb func(Event)) {
key := len(used)
used = append(used, key)
tmp := []uint16{}
uptmp := []uint16{}
for _, v := range cmds {
@ -160,7 +159,6 @@ func Process(evChan <-chan Event) (out chan bool) {
uppressed = make(map[uint16]bool, 256)
cbs[v](ev)
}
}
}
}