Skip to content

How to detect mouse button 3 or 4 (side buttons on mouse) #703

Closed Answered by RensTillmann
RensTillmann asked this question in Q&A
Discussion options

You must be logged in to vote

I think I found the solution by importing robotn/gohook as hook and listeining to below event:

go func() {
	fmt.Println("--- Listening for mouse events ---")
	hook.Register(hook.MouseDown, []string{}, func(e hook.Event) {
		fmt.Printf("Mouse event detected: Button=%d\n", e.Button)
		if e.Button == 4 {
			
		}
	})
	s := hook.Start()
	<-hook.Process(s)
}()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RensTillmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant