exp/textinput: bug fix: don't send events on Enter on desktop browsers

Apparently sending an event on pressing Enter on desktops could sometimes
duplicate texts.

Closes #3041
This commit is contained in:
Hajime Hoshi 2024-07-15 00:58:29 +09:00
parent 71b7cedc5b
commit 7b1965e28f

View File

@ -79,7 +79,7 @@ func (t *textInput) init() {
if e.Get("code").String() == "Tab" {
e.Call("preventDefault")
}
if e.Get("code").String() == "Enter" || e.Get("key").String() == "Enter" {
if ui.IsVirtualKeyboard() && (e.Get("code").String() == "Enter" || e.Get("key").String() == "Enter") {
// Ignore Enter key to avoid ebiten.IsKeyPressed(ebiten.KeyEnter) unexpectedly becomes true.
e.Call("preventDefault")
ui.Get().UpdateInputFromEvent(e)