Skip to content
/ gohook Public
forked from robotn/gohook

GoHook, Go global keyboard and mouse listener hook

License

Notifications You must be signed in to change notification settings

haunt98/gohook

 
 

Repository files navigation

gohook

Build Status CircleCI Status Appveyor Go Report Card GoDoc

package main

import (
	"fmt"

	hook "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.

About

GoHook, Go global keyboard and mouse listener hook

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 95.5%
  • Go 4.5%