Skip to content

Commit

Permalink
Update: update examples and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vcaesar committed Feb 8, 2025
1 parent 0d69fe6 commit f049036
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
24 changes: 14 additions & 10 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
Expand Down Expand Up @@ -69,12 +82,3 @@ func base() {
}
}
}

func main() {
registerEvent()

base()

add()
addMouse()
}
2 changes: 0 additions & 2 deletions hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -160,7 +159,6 @@ func Process(evChan <-chan Event) (out chan bool) {
uppressed = make(map[uint16]bool, 256)
cbs[v](ev)
}

}
}
}
Expand Down

0 comments on commit f049036

Please sign in to comment.