From faa404a6527d0ac13952b31837691c9119450647 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 17 Oct 2024 17:50:04 -0700
Subject: [PATCH] If we get a newline character, treat it as SDLK_RETURN
Fixes https://github.com/libsdl-org/SDL/issues/10679
---
src/events/SDL_keyboard.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index 438311ba4d453..ae533db8cbe7b 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -637,7 +637,12 @@ void SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Keymod modstate = SDL_KMOD_NONE;
- SDL_Scancode scancode = SDL_GetKeymapScancode(keyboard->keymap, ch, &modstate);
+ SDL_Scancode scancode;
+
+ if (ch == '\n') {
+ ch = SDLK_RETURN;
+ }
+ scancode = SDL_GetKeymapScancode(keyboard->keymap, ch, &modstate);
// Make sure we have this keycode in our keymap
if (scancode == SDL_SCANCODE_UNKNOWN && ch < SDLK_SCANCODE_MASK) {