robotn / gohook

GoHook, Go global keyboard and mouse listener hook
MIT License
314 stars 44 forks source link

How do I approach the keyboard tab to know the click status? #9

Closed buYoung closed 4 years ago

buYoung commented 4 years ago

s := hook.Start() defer hook.End() for { select { case i:= <- s : fmt.Printf("%s \n", i) }

I wrote it like the above code and proceeded with the test. The only result I want is HOLD or DOWN while I'm pressing TAB, But I've seen that UP/DOWN//HOLD is constantly output.

How do I solve this problem?

cauefcr commented 4 years ago

You could use a boolean, when tab is pressed set it to true, when tab is let go set it to false, and use that boolean for your interest.

You could also check out my fork of gohook to see if it's interface suits you better. https://github.com/cauefcr/ghook

vcaesar commented 4 years ago

Can give me a PR? Thx.

cauefcr commented 4 years ago

Even if it's not backwards compatible?

On Fri, Apr 17, 2020, 12:17 PM vz notifications@github.com wrote:

Can give me a PR? Thx.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/robotn/gohook/issues/9#issuecomment-615302801, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACY42HJYONM6DNPC65XMNKLRNBXHTANCNFSM4MJHBU2A .

buYoung commented 4 years ago

Oh, I was mistaken. While I was pressing the TAB key, I thought that the HOLD and DOWN were continuously output, and the UP was also output.

EXAPLE) s := hook.Start() defer hook.End() d := false for { select { case i := <-s: if i.Rawcode == 9 { switch i.Kind { case 3,4: d = true case 5: d= false } } } println(d) }