Skip to content

[GLFW] Allow Backspace and Tab in <input> and <textarea> elements - #28143

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:glfw-input-backspace
Open

sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:glfw-input-backspace

Conversation

@sbc100

@sbc100 sbc100 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Previously GLFW.onKeydown unconditionally called event.preventDefault() on Backspace and Tab keydown events on window, preventing users from deleting text or tabbing between HTML <input> and <textarea> elements on the same page.

Based on #22879 by @uysalibov and tests from #23285 by @kripken.

Fixes: #22866

Previously `GLFW.onKeydown` unconditionally called
`event.preventDefault()` on `Backspace` and `Tab` keydown events on
`window`, preventing users from deleting text or tabbing between HTML
`<input>` and `<textarea>` elements on the same page.

Based on emscripten-core#22879 by @uysalibov and tests from emscripten-core#23285 by @kripken.

Fixes: emscripten-core#22866

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies libglfw.js to prevent default backspace and tab behaviors only when the event target is not an INPUT or TEXTAREA element, and adds a browser test to verify this functionality. The review feedback points out two important issues: first, simulateKeyEvent is undefined in the test file, which will lead to a runtime error; second, the event handler should guard against a null event.target and also avoid preventing default behaviors on contenteditable elements.

Comment thread test/browser/test_glfw_events.c Resolved
Comment thread src/lib/libglfw.js Resolved
@sbc100
sbc100 requested a review from kripken November 6, 2026 23:15
@kripken

kripken commented Nov 7, 2026

Copy link
Copy Markdown
Member

What do other backends do here? Assuming the same, it sounds fine to me, but it would still be a breaking change I think, so it needs a changelog entry?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

library_glfw.js blocks html inputs

2 participants