Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple events occur in single input #47

Open
1 task done
thewh1teagle opened this issue Apr 4, 2024 · 0 comments
Open
1 task done

Multiple events occur in single input #47

thewh1teagle opened this issue Apr 4, 2024 · 0 comments

Comments

@thewh1teagle
Copy link

I use gohook in the project github.com/shortcut and publish it to macOS / Linux / Windows.

In macOS if I push some key and hold it will send multiple keyDown events altought I clicked only once and holding.
in Windows if I push some key without holding it send multiple keyDown events, if I hold then also same as macOS - multiple events are sent for simple hit on keys.

  • Gohook version c94ab29
  • Go version: go version go1.22.0 darwin/arm64
  • Gcc version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
  • Operating system and bit: macOS
  • Resolution:
  • Can you reproduce the bug at Examples:
    • Yes

main.go#L181

func registerShortcuts(shortcuts []Shortcut) {
	for _, shortcut := range shortcuts {
		fmt.Printf("Register shortcut %v\n", shortcut)
		hook.Register(hook.KeyDown, shortcut.Keys, func(e hook.Event) {
			fmt.Printf("Shortcut <%s> activated\n", shortcut.Name)
			command := strings.Split(shortcut.Command, " ")
			cmd := exec.Command(command[0], command[1:]...)

			if err := cmd.Start(); err != nil {
				fmt.Printf("Error executing command for shortcut <%s>: %v\n", shortcut.Name, err)
			}
		})
	}
}
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

No branches or pull requests

1 participant