Skip to content

Commit

Permalink
exp/textinput: bug fix: don't send events on Enter on desktop browsers
Browse files Browse the repository at this point in the history
Apparently sending an event on pressing Enter on desktops could sometimes
duplicate texts.

Closes #3041
  • Loading branch information
hajimehoshi committed Jul 14, 2024
1 parent af29b71 commit cde4c4f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion exp/textinput/textinput_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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)
Expand Down

0 comments on commit cde4c4f

Please sign in to comment.