键盘事件监控, from : https://github.com/robotn/gohook.git
Go to file
2024-10-07 20:32:57 +00:00
.github Update: update CI and go mod 2024-08-26 16:42:12 -07:00
chan fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
event fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
examples fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
hook fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
test fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
.gitignore fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
appveyor.yml Update: update CI and go mod 2024-08-26 16:42:12 -07:00
circle.yml fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
event.go fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
extern.go fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
go.mod Update go.mod 2024-10-07 13:32:54 -07:00
go.sum Update: update CI and go mod 2024-08-26 16:42:12 -07:00
hook_test.go fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
hook.go fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
keycode.go fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
LICENSE fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
README.md fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
tables.go fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08: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.