diff --git a/internal/ui/input_js.go b/internal/ui/input_js.go index 4f5ff6c41..612ab9e24 100644 --- a/internal/ui/input_js.go +++ b/internal/ui/input_js.go @@ -416,3 +416,13 @@ var uiKeyToJSKey = map[Key]js.Value{ KeyNumpad8: js.ValueOf("8"), KeyNumpad9: js.ValueOf("9"), } + +func (i *InputState) resetForBlur() { + for j := range i.KeyPressed { + i.KeyPressed[j] = false + } + for j := range i.MouseButtonPressed { + i.MouseButtonPressed[j] = false + } + i.Touches = i.Touches[:0] +} diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 86ea9c0a2..8f507ad68 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -693,6 +693,12 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) { go u.appendDroppedFiles(data) return nil })) + + // Blur + v.Call("addEventListener", "blur", js.FuncOf(func(this js.Value, args []js.Value) any { + u.inputState.resetForBlur() + return nil + })) } func (u *UserInterface) appendDroppedFiles(data js.Value) {