Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robotn/gohook
GoHook, Go global keyboard and mouse listener hook
https://github.com/robotn/gohook
go golang hook keyboard listener mouse-events
Last synced: 3 months ago
JSON representation
GoHook, Go global keyboard and mouse listener hook
- Host: GitHub
- URL: https://github.com/robotn/gohook
- Owner: robotn
- License: mit
- Created: 2017-01-21T08:52:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-26T23:42:18.000Z (5 months ago)
- Last Synced: 2024-08-27T02:12:31.550Z (5 months ago)
- Topics: go, golang, hook, keyboard, listener, mouse-events
- Language: C
- Homepage:
- Size: 195 KB
- Stars: 308
- Watchers: 11
- Forks: 43
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome - robotn/gohook - events pushed_at:2024-08 star:0.3k fork:0.0k GoHook, Go global keyboard and mouse listener hook (C)
README
# gohook
[![Build Status](https://github.com/robotn/gohook/workflows/Go/badge.svg)](https://github.com/robotn/gohook/commits/master)
[![CircleCI Status](https://circleci.com/gh/robotn/gohook.svg?style=shield)](https://circleci.com/gh/robotn/gohook)
![Appveyor](https://ci.appveyor.com/api/projects/status/github/robotn/gohook?branch=master&svg=true)
[![Go Report Card](https://goreportcard.com/badge/github.com/robotn/gohook)](https://goreportcard.com/report/github.com/robotn/gohook)
[![GoDoc](https://godoc.org/github.com/robotn/gohook?status.svg)](https://godoc.org/github.com/robotn/gohook)## Requirements (Linux):
[Robotgo-requirements-event](https://github.com/go-vgo/robotgo#requirements)
## Install:
With Go module support (Go 1.11+), just import:
```go
import "github.com/robotn/gohook"
```## Examples:
```Go
package mainimport (
"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](https://github.com/kwhat/libuiohook).