键盘事件监控, from : https://github.com/robotn/gohook.git
Go to file
2024-08-26 16:42:12 -07:00
.github Update: update CI and go mod 2024-08-26 16:42:12 -07:00
chan update version and gomod pkg 2020-05-20 10:55:32 -04:00
event Add more examples code 2022-02-09 09:26:46 -08:00
examples Add more examples code 2022-02-09 09:26:46 -08:00
hook Changed to both two license 2021-09-09 10:34:48 -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: update CI and go mod 2024-08-26 16:42:12 -07:00
circle.yml update circle.yml 2020-02-22 12:11:56 -04:00
event.go Move robotgo event code to event.go 2022-01-02 16:24:25 -04:00
extern.go update go send json.Unmarshal error log 2019-06-22 12:58:07 -04:00
go.mod Update: update CI and go mod 2024-08-26 16:42:12 -07:00
go.sum Update: update CI and go mod 2024-08-26 16:42:12 -07:00
hook_test.go add keycode test support 2020-02-23 11:02:58 -04:00
hook.go Update: update godoc and clean go.yml 2023-03-02 17:37:06 -08:00
keycode.go Update: update godoc and clean go.yml 2023-03-02 17:37:06 -08:00
LICENSE Changed to both two license 2021-09-09 10:34:48 -04:00
README.md Update README.md 2021-12-24 14:05:52 -04:00
tables.go add more keycodes and update appveyor.yml 2021-08-08 14:42:54 -04:00

gohook

Build Status CircleCI Status Appveyor Go Report Card GoDoc

Requirements (Linux):

Robotgo-requirements-event

Install:

With Go module support (Go 1.11+), just import:

import "github.com/robotn/gohook"

Examples:

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.