mirror of
https://github.com/robotn/gohook.git
synced 2024-12-04 12:03:25 +08:00
update godoc and example
This commit is contained in:
parent
05ca764c42
commit
4f8581a884
@ -6,14 +6,14 @@ import (
|
|||||||
hook "github.com/robotn/gohook"
|
hook "github.com/robotn/gohook"
|
||||||
)
|
)
|
||||||
|
|
||||||
func addEvent() {
|
func registerEvent() {
|
||||||
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
|
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
|
||||||
hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
|
hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
|
||||||
fmt.Println("ctrl-shift-q")
|
fmt.Println("ctrl-shift-q")
|
||||||
hook.End()
|
hook.End()
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Println("--- Please press w---")
|
fmt.Println("--- Please press w ---")
|
||||||
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
|
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
|
||||||
fmt.Println("w-")
|
fmt.Println("w-")
|
||||||
})
|
})
|
||||||
@ -54,7 +54,7 @@ func base() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
addEvent()
|
registerEvent()
|
||||||
|
|
||||||
base()
|
base()
|
||||||
|
|
||||||
|
4
hook.go
4
hook.go
@ -156,7 +156,7 @@ func Process(evChan <-chan Event) (out chan bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// String return hook kind string
|
// String return formatted hook kind string
|
||||||
func (e Event) String() string {
|
func (e Event) String() string {
|
||||||
switch e.Kind {
|
switch e.Kind {
|
||||||
case HookEnabled:
|
case HookEnabled:
|
||||||
@ -202,7 +202,7 @@ func (e Event) String() string {
|
|||||||
return fmt.Sprintf("%v - Event: {Kind: FakeEvent}", e.When)
|
return fmt.Sprintf("%v - Event: {Kind: FakeEvent}", e.When)
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Unknown event, contact the mantainers"
|
return "Unknown event, contact the mantainers."
|
||||||
}
|
}
|
||||||
|
|
||||||
// RawcodetoKeychar rawcode to keychar
|
// RawcodetoKeychar rawcode to keychar
|
||||||
|
Loading…
Reference in New Issue
Block a user