robotn / gohook

GoHook, Go global keyboard and mouse listener hook
MIT License
324 stars 43 forks source link

Key down for Arrow Down is never invoked. #26

Open takuyahara opened 4 years ago

takuyahara commented 4 years ago

As titled. Rawcode: 125 is Arrow Down and the others are other arrows.

$ go run example/main.go 
--- Please press ctrl + shift + q to stop hook ---
--- Please press w---
ctrl-shift-q
hook start...
hook:  2020-10-29 18:21:20.502464 +0900 JST m=+4.514493252 - Event: {Kind: HookEnabled}
hook:  2020-10-29 18:21:20.502482 +0900 JST m=+4.514510837 - Event: {Kind: KeyUp, Rawcode: 12, Keychar: 65535}
hook:  2020-10-29 18:21:20.610329 +0900 JST m=+4.622362170 - Event: {Kind: KeyUp, Rawcode: 59, Keychar: 65535}
hook:  2020-10-29 18:21:20.610347 +0900 JST m=+4.622380580 - Event: {Kind: KeyUp, Rawcode: 56, Keychar: 65535}
^[[Chook:  2020-10-29 18:21:25.652731 +0900 JST m=+9.664954525 - Event: {Kind: KeyDown, Rawcode: 124, Keychar: 29}
hook:  2020-10-29 18:21:25.652745 +0900 JST m=+9.664968877 - Event: {Kind: KeyHold, Rawcode: 124, Keychar: 65535}
hook:  2020-10-29 18:21:25.708012 +0900 JST m=+9.720237562 - Event: {Kind: KeyUp, Rawcode: 124, Keychar: 65535}
^[[Dhook:  2020-10-29 18:21:28.888841 +0900 JST m=+12.901185835 - Event: {Kind: KeyHold, Rawcode: 123, Keychar: 65535}
hook:  2020-10-29 18:21:28.888842 +0900 JST m=+12.901187556 - Event: {Kind: KeyDown, Rawcode: 123, Keychar: 28}
hook:  2020-10-29 18:21:28.997212 +0900 JST m=+13.009561845 - Event: {Kind: KeyUp, Rawcode: 123, Keychar: 65535}
^[[Ahook:  2020-10-29 18:21:37.633044 +0900 JST m=+21.645718726 - Event: {Kind: KeyHold, Rawcode: 126, Keychar: 65535}
hook:  2020-10-29 18:21:37.633055 +0900 JST m=+21.645729381 - Event: {Kind: KeyDown, Rawcode: 126, Keychar: 30}
hook:  2020-10-29 18:21:37.687625 +0900 JST m=+21.700301346 - Event: {Kind: KeyUp, Rawcode: 126, Keychar: 65535}
^[[Bhook:  2020-10-29 18:21:40.913595 +0900 JST m=+24.926393683 - Event: {Kind: KeyHold, Rawcode: 125, Keychar: 65535}
hook:  2020-10-29 18:21:40.965137 +0900 JST m=+24.977936924 - Event: {Kind: KeyUp, Rawcode: 125, Keychar: 65535}
hook:  2020-10-29 18:21:46.670449 +0900 JST m=+30.683463769 - Event: {Kind: KeyHold, Rawcode: 125, Keychar: 65535}
^[[Bhook:  2020-10-29 18:21:46.775177 +0900 JST m=+30.788196695 - Event: {Kind: KeyUp, Rawcode: 125, Keychar: 65535}
^[[Bhook:  2020-10-29 18:21:50.221418 +0900 JST m=+34.234566667 - Event: {Kind: KeyHold, Rawcode: 125, Keychar: 65535}
vs-123 commented 4 years ago

I don't think arrow keys are supported because they don't work for me. Try using this code and pressing arrow keys to see if they respond:

package main
import (
  "fmt"
  hook "github.com/robotn/gohook"
)

func main() {

  fmt.Println("Press any key")

  hook.Register(hook.KeyDown, []string{}, func(e hook.Event) {

    fmt.Println(e)

  })

  s := hook.Start()

  <-hook.Process(s)
}
takuyahara commented 4 years ago

Only arrow down key doesn't respond.

vs-123 commented 4 years ago

Maybe try changing the keyboard if possible to see if it works.