键盘事件监控, from : https://github.com/robotn/gohook.git
Go to file
2021-04-08 12:23:23 -04:00
.github/workflows update CI yml 2021-02-25 11:36:14 -04:00
chan update version and gomod pkg 2020-05-20 10:55:32 -04:00
event add center mouse and update code style 2019-03-05 15:29:54 -04:00
examples update godoc and example 2020-12-02 13:01:20 -04:00
hook update code style 2020-06-29 11:50:14 -04:00
test add example and update code style 2019-02-19 11:32:48 -04:00
.gitignore update .gitignore 2019-04-13 13:26:57 -04:00
appveyor.yml update appveyor.yml 2021-04-08 12:23:23 -04:00
circle.yml update circle.yml 2020-02-22 12:11:56 -04:00
extern.go update go send json.Unmarshal error log 2019-06-22 12:58:07 -04:00
go.mod update go mod and appveyor.yml 2020-11-16 11:27:15 -04:00
go.sum update go mod and appveyor.yml 2020-11-16 11:27:15 -04:00
hook_test.go add keycode test support 2020-02-23 11:02:58 -04:00
hook.go update godoc and example 2020-12-02 13:01:20 -04:00
keycode.go add robotgo keycode to gohook 2020-05-19 11:01:25 -04:00
LICENSE Initial commit 2017-01-21 16:52:05 +08:00
README.md Update README.md 2020-09-07 10:27:44 -04:00
tables.go refactor code, fixed bug and api 2019-02-20 11:07:25 -04:00

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.