Skip to content

Commit 923123a

Browse files
committed
emscripten: Let SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT accept "#none"
This is used to say "don't even try to listen for keypresses," for apps that are managing this outside of SDL. Fixes #10292.
1 parent c603a9c commit 923123a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/SDL3/SDL_hints.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ extern "C" {
730730
* - "#document": the javascript document object
731731
* - "#screen": the javascript window.screen object
732732
* - "#canvas": the WebGL canvas element
733-
* - "": Don't bind anything at all
733+
* - "#none": Don't bind anything at all
734734
* - any other string without a leading # sign applies to the element on the
735735
* page with that ID.
736736
*

src/video/emscripten/SDL_emscriptenevents.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1029,11 +1029,11 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data)
10291029

10301030
// Keyboard events are awkward
10311031
keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
1032-
if (!keyElement) {
1032+
if (!keyElement || !*keyElement) {
10331033
keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW;
10341034
}
10351035

1036-
if (*keyElement) {
1036+
if (SDL_strcmp(keyElement, "#none") != 0) {
10371037
emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
10381038
emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
10391039
emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);

0 commit comments

Comments
 (0)