prevent-alt-win-menu

Crates.ioprevent-alt-win-menu
lib.rsprevent-alt-win-menu
version0.2.2
created_at2025-06-18 02:12:05.068357+00
updated_at2025-06-23 09:12:41.993656+00
descriptionPrevents the menu bar or Start menu from appearing when the Alt or Windows key is released
homepage
repositoryhttps://github.com/noriapi/prevent-alt-win-menu
max_upload_size
id1716462
size52,298
(noriapi)

documentation

README

prevent-alt-win-menu

github Crates.io Version docs.rs

Prevents the menu bar or Start menu from appearing when the Alt or Windows key is released on Windows.

Overview

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.

Platform

  • Windows only

Quick Start

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");

How it works

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.

Configuration

  • 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.

Limitations

  • May interfere with other hooks that rely on raw Alt or Win key events.

License

MIT OR Apache-2.0

Commit count: 19

cargo fmt