Win32: Fix scancode for media keys

Media key events were incorrectly reported with a scancode of 0x100.

This is based on a snippet by dougbinks in #2625.

Fixes #1768
Closes #2417
Fixes #2625
diff --git a/README.md b/README.md
index 90cf45e..416de2a 100644
--- a/README.md
+++ b/README.md
@@ -127,6 +127,7 @@
  - Updated minimum CMake version to 3.16 (#2541)
  - Removed support for building with original MinGW (#2540)
  - [Win32] Removed support for Windows XP and Vista (#2505)
+ - [Win32] Bugfix: Media keys were reported with a scancode of 256 (#1768,#2417,#2625)
  - [Cocoa] Added `QuartzCore` framework as link-time dependency
  - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
  - [Cocoa] Bugfix: Cmd+Period, Ctrl+Tab and Ctrl+Esc key events were not emitted
diff --git a/src/win32_window.c b/src/win32_window.c
index 6427a67..8f83a9a 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -711,11 +711,12 @@
             const int mods = getKeyMods();
 
             scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff));
-            if (!scancode)
+            if (!(scancode & 0xff))
             {
-                // NOTE: Some synthetic key messages have a scancode of zero
-                // HACK: Map the virtual key back to a usable scancode
-                scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC);
+                // NOTE: Both media keys and the synthetic key messages from Windows
+                //       Clipboard History are reported with a scancode of zero
+                // HACK: Map the virtual key to a scancode but preserve extended bit
+                scancode |= MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC);
             }
 
             // HACK: Alt+PrtSc has a different scancode than just PrtSc