Prevents the menu bar or Start menu from appearing when the Alt or Windows key is released on Windows.
On Windows, releasing the Alt
key typically activates the menu bar of the focused
window (if it has one), and releasing the Windows
key opens the Start menu.
This crate allows you to suppress these behaviors, which is useful for apps with
custom global keyboard handling or immersive fullscreen UIs.
- Windows only
Call [start
] at the beginning of your application. You do not need to hold on
to the returned [JoinHandles
] unless you explicitly want to join()
the threads
or detect their termination.
use prevent_alt_win_menu::event_handler::Config;
use prevent_alt_win_menu::start;
// Starts the suppression logic in background threads
let _ = start(Config::default()).expect("failed to start menu suppression");
This crate installs a low-level keyboard hook using SetWindowsHookExW
and listens
for WM_KEYUP
events of:
-
VK_MENU
/VK_LMENU
/VK_RMENU
(Alt key) -
VK_LWIN
/VK_RWIN
(Left/Right Windows key)
When such a key is released, a dummy key-up event (by default, VK__none_
) is programmatically
sent immediately.
This causes Windows to interpret the input as a hotkey sequence rather than a standalone
key release — effectively suppressing the default menu activation behavior.
-
Custom dummy key: You can specify any virtual key code to be used as the dummy key.
-
Conditional suppression: A callback function allows you to decide at runtime whether or not to send the dummy key, based on the released key or app state.
- May interfere with other hooks that rely on raw
Alt
orWin
key events.
MIT OR Apache-2.0