During a test where multiple keys are pressed and held down simultaneously, only the last key pressed continually triggers the hold event.Even under the above conditions, only up to 6 keys can be pressed simultaneously.
LuSrackhall opened this issue · 1 comments
During a test where multiple keys are pressed and held down simultaneously, only the last key pressed continually triggers the hold event. Intuitively, if I am holding down multiple keys, each should be able to continually trigger its corresponding hold event.
Even under the above conditions, only up to 6 keys can be pressed simultaneously. (When I am holding down 6 keys and start pressing a 7th key or more, no further keyboard events can be detected.)
I am not sure if these two issues are due to my personal device setup:
-
Test system: Windows 10
-
Gohook version (or commit ref): last
-
Go version: go1.22.0
-
Gcc version: gcc-13.1.0/configure --host=x86_64-w64-mingw32
-
Operating system and bit: win10 and 64
-
Resolution: 1080p
-
Can you reproduce the bug at Examples:
- [*] Yes (provide example code)
-
Provide example code:
package main
import (
hook "github.com/robotn/gohook"
)
func main() {
keyEventListen()
}
func keyEventListen() {
evChan := hook.Start()
defer hook.End()
keycode_keycodeChan_map := make(map[uint16]chan hook.Event)
for ev := range evChan {
if ev.Kind == 4 || ev.Kind == 5 {
if _, exists := keycode_keycodeChan_map[ev.Keycode]; exists {
keycode_keycodeChan_map[ev.Keycode] <- ev
} else {
keycode_keycodeChan_map[ev.Keycode] = make(chan hook.Event)
go handleKeyEvent(keycode_keycodeChan_map[ev.Keycode])
keycode_keycodeChan_map[ev.Keycode] <- ev
}
}
}
}
func handleKeyEvent(evChan chan hook.Event) {
var key_down_soundIsRun bool = false
for ev := range evChan {
if ev.Kind == 4 {
println("hold")
println(ev.Keycode)
if !key_down_soundIsRun {
println("仅播放 key_down 声音")
key_down_soundIsRun = true
}
}
if ev.Kind == 5 {
println("up")
println(ev.Keycode)
println("仅播放 key_up 声音")
key_down_soundIsRun = false
}
}
}
- Log gist:
Description
...
Hardware Limitations
- Keyboard Hardware Limitations:
- Most standard keyboards (especially older or cheaper models) do indeed have limitations when multiple keys are pressed simultaneously. These limitations are commonly referred to as “Keyboard Ghosting” and “Key Rollover”.
- Some keyboards can only detect the pressing of 2 or 3 keys at the same time, while more advanced keyboards may support 6-key rollover (6KRO) or full-key rollover (NKRO).
- 6-Key Rollover (6KRO):
- Many keyboards, including some mechanical keyboards, support 6-key rollover. This means that they can detect the pressing of up to 6 keys simultaneously without any conflicts.