SDL: examples/snake: Use position dependant key codes for keyboard input

From f78bdbd96c7362eff29a093f12204afa2cd881f7 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Mon, 17 Aug 2026 22:10:28 +0100
Subject: [PATCH] examples/snake: Use position dependant key codes for keyboard
 input

---
 examples/demo/01-snake/snake.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/examples/demo/01-snake/snake.c b/examples/demo/01-snake/snake.c
index 5c63251d8773b..91ffdc789f471 100644
--- a/examples/demo/01-snake/snake.c
+++ b/examples/demo/01-snake/snake.c
@@ -211,28 +211,28 @@ void snake_step(SnakeContext *ctx)
     }
 }
 
-static SDL_AppResult handle_key_event_(SnakeContext *ctx, SDL_Scancode key_code)
+static SDL_AppResult handle_key_event_(SnakeContext *ctx, SDL_Keycode key_code)
 {
     switch (key_code) {
     /* Quit. */
-    case SDL_SCANCODE_ESCAPE:
-    case SDL_SCANCODE_Q:
+    case SDLK_ESCAPE:
+    case SDLK_Q:
         return SDL_APP_SUCCESS;
     /* Restart the game as if the program was launched. */
-    case SDL_SCANCODE_R:
+    case SDLK_R:
         snake_initialize(ctx);
         break;
     /* Decide new direction of the snake. */
-    case SDL_SCANCODE_RIGHT:
+    case SDLK_RIGHT:
         snake_redir(ctx, SNAKE_DIR_RIGHT);
         break;
-    case SDL_SCANCODE_UP:
+    case SDLK_UP:
         snake_redir(ctx, SNAKE_DIR_UP);
         break;
-    case SDL_SCANCODE_LEFT:
+    case SDLK_LEFT:
         snake_redir(ctx, SNAKE_DIR_LEFT);
         break;
-    case SDL_SCANCODE_DOWN:
+    case SDLK_DOWN:
         snake_redir(ctx, SNAKE_DIR_DOWN);
         break;
     default:
@@ -375,7 +375,7 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
     case SDL_EVENT_JOYSTICK_HAT_MOTION:
         return handle_hat_event_(ctx, event->jhat.value);
     case SDL_EVENT_KEY_DOWN:
-        return handle_key_event_(ctx, event->key.scancode);
+        return handle_key_event_(ctx, event->key.key);
     default:
         break;
     }