Skip to content

Commit

Permalink
add more examples code and add log print
Browse files Browse the repository at this point in the history
  • Loading branch information
vcaesar committed May 21, 2020
1 parent 419a034 commit 6ca4fbe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,25 @@ import (
hook "github.com/robotn/gohook"
)

func addEvent() {
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)
}

// hook listen and return values using detailed examples
func add() {
fmt.Println("hook add...")
s := hook.Start()
defer hook.End()

Expand All @@ -27,6 +44,7 @@ func add() {

// base hook example
func base() {
fmt.Println("hook start...")
evChan := hook.Start()
defer hook.End()

Expand All @@ -36,6 +54,8 @@ func base() {
}

func main() {
addEvent()

base()

add()
Expand Down

0 comments on commit 6ca4fbe

Please sign in to comment.