键盘事件监控, from : https://github.com/robotn/gohook.git
Go to file
2024-06-16 04:44:20 +08:00
.github fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08: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 fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08: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 fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08:00
go.sum fix 修复KeyUp事件无效 2024-06-16 04:44:20 +08: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.