Skip to content

Multiple events occur in single input #47

@thewh1teagle

Description

@thewh1teagle

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)
			}
		})
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions