From 8be6db493eab58e7f82344137980acb1333999d6 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 25 Oct 2026 15:18:01 -0400
Subject: [PATCH] SDL_keyboard.h: add notes about threading vs
SDL_GetKeyboardState.
Fixes #16562.
---
include/SDL3/SDL_keyboard.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/SDL3/SDL_keyboard.h b/include/SDL3/SDL_keyboard.h
index 8f3e8d3e11062..6b6bb36d47b9f 100644
--- a/include/SDL3/SDL_keyboard.h
+++ b/include/SDL3/SDL_keyboard.h
@@ -146,6 +146,13 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
* Note: This function doesn't take into account whether shift has been
* pressed or not.
*
+ * Note that this function is "thread safe," in that calling it from two
+ * threads at once will return the same array and that it won't be
+ * reallocated or free'd without warning, as more events arrive, the
+ * contents of this array may change without warning or any sort of thread
+ * synchronization. For apps that need precision, it is better to use the
+ * key events in the SDL event queue.
+ *
* \param numkeys if non-NULL, receives the length of the returned array.
* \returns a pointer to an array of key states.
*