Send navigation, Windows and Menu keys with the extended flag on Windows (#17174)

This commit is contained in:
giotic authored and GitHub committed 2026-11-22 15:38:59 +08:00
1 parent 8e1433d4a2
commit 534b047525
1 file changed
+6
+6
View File
@@ -61,6 +61,12 @@ fn keybd_event(mut flags: u32, vk: u16, scan: u16) -> DWORD {
LAYOUT = GetKeyboardLayout(current_window_thread_id);
}
scan = MapVirtualKeyExW(vk as _, 0, LAYOUT) as _;
// Without the extended flag, VM consoles and DirectX games read the navigation
// keys as the numpad keys that share their scan codes, and VM consoles ignore the
// Windows and Menu keys.
if matches!(vk, EVK_PRIOR..=EVK_DOWN | EVK_INSERT | EVK_DELETE | EVK_LWIN..=EVK_APPS) {
flags |= KEYEVENTF_EXTENDEDKEY;
}
}
}