micmonay / keybd_event

For simulate key press in Linux, Windows and Mac in golang
MIT License
376 stars 56 forks source link

Release keys for macOS users #11

Closed karreiro closed 5 years ago

karreiro commented 5 years ago

Hi @micmonay, very interesting project! :-)

I'm woking in a bot that plays Stardew Valley, and I've noticed an odd behaviour on macOS. When a key is pressed, it's not being released.

I've checked this doc, and apparently this PR fixes the issue.

See my bot running before my changes: 2019-05-19 16 48 22

..and here's my bot running with the changes proposed by this PR: 2019-05-19 16 47 07

Btw, here's the code that my bot performs:


package main

import (
    "time"

    "github.com/micmonay/keybd_event"
)

func main() {

    time.Sleep(1 * time.Second)

    kb, err := keybd_event.NewKeyBonding()
    if err != nil {
        panic(err)
    }

    kb.SetKeys(keybd_event.VK_D)
    kb.Launching()
}
micmonay commented 5 years ago

Hi

Big thanks for your PR. I don't find this on my tests because of my Mac OS, continuous press on the key haven't no affect the output.

Good week !