Categorygithub.com/robotn/gohook
modulepackage
0.41.0
Repository: https://github.com/robotn/gohook.git
Documentation: pkg.go.dev

# README

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.

# Packages

No description provided by the author
No description provided by the author

# Functions

AddEvent add event listener, parameters for the string type, the keyboard corresponding key parameters, mouse arguments: mleft, center, mright, wheelDown, wheelUp, wheelLeft, wheelRight.
AddEvents add global event hook hook.AddEvents("q") hook.AddEvents("q", "ctrl") hook.AddEvents("q", "ctrl", "shift").
AddMouse add mouse event hook mouse arguments: left, center, right, wheelDown, wheelUp, wheelLeft, wheelRight.
AddMousePos add listen mouse event pos hook.

# Variables

Keycode defines the robotgo hook key's code map.
MouseMap defines the robotgo hook mouse's code map.
Special defines the special key map.