From e262a579ea577e316b6b81af8fa01c237e1c4b4d Mon Sep 17 00:00:00 2001 From: willow Date: Wed, 18 Jun 2025 23:14:35 +0800 Subject: [PATCH] fix: Issues #65 --- hook.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hook.go b/hook.go index a15e7ac..5e5031b 100644 --- a/hook.go +++ b/hook.go @@ -114,6 +114,19 @@ func allPressed(pressed map[uint16]bool, keys ...uint16) bool { return true } +func keyRegistered(evKeyCode uint16, keys ...uint16) bool { + // Handle empty keys list case (consider all keys registered) + if len(keys) == 0 { + return true + } + for _, k := range keys { + if k == evKeyCode { + return true + } + } + return false +} + // Register register gohook event func Register(when uint8, cmds []string, cb func(Event)) { key := len(used) @@ -151,6 +164,9 @@ func Process(evChan <-chan Event) (out chan bool) { if !asyncon { break } + if !keyRegistered(ev.Keycode, keys[v]...) { + continue + } if allPressed(pressed, keys[v]...) { cbs[v](ev)