diff --git a/internal/ui/input_glfw_darwin.go b/internal/ui/input_glfw_darwin.go index 23aa2057a..81305a9c3 100644 --- a/internal/ui/input_glfw_darwin.go +++ b/internal/ui/input_glfw_darwin.go @@ -36,6 +36,13 @@ func (i *Input) updateKeys(window *glfw.Window) { i.keyPressed = map[C.CGKeyCode]bool{} } + if window.GetAttrib(glfw.Focused) != glfw.True { + for _, cgKey := range uiKeyToCGKey { + i.keyPressed[C.CGKeyCode(cgKey)] = false + } + return + } + // Record the key states instead of calling CGEventSourceKeyState every time at IsKeyPressed. // There is an assumption that the key states never change during one tick. // Without this assumption, some functions in inpututil would not work correctly.