Skip to content

Conversation

@Golevka2001
Copy link

Please provide Issues links to:

Provide test code:

package main

import (
	"fmt"
	"time"

	hook "github.com/robotn/gohook"
)

func main() {
	s := hook.Start()
	defer hook.End()

	tout := time.After(time.Hour * 2)
	done := false
	for !done {
		select {
		case i := <-s:
			if i.Kind == hook.KeyDown || i.Kind == hook.KeyHold {
				if i.Keychar == 'q' {
					done = true
				}
				fmt.Printf("kind: %v, rawcode: %v, keyname: \"%s\"\n", i.Kind, i.Rawcode, hook.RawcodetoKeychar(i.Rawcode))
			}

		case <-tout:
			fmt.Print("Done.")
			done = true
		}
	}
}

Description

As mentioned in #60, the keycode on macOS keyboards does not match the one defined in tables.go.

So I referred to https://ritter.ist.psu.edu/projects/RUI/macosx/rui.c and added rawcode mappings for macOS.

This is the test result:

(the first image corresponds to the modified code)
Snipaste_2025-05-21_15-54-00

(and the second image corresponds to the original code)
Snipaste_2025-05-21_15-56-13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant