Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot detect key presses that are handled by window manager #124

Closed
blokeley opened this issue May 4, 2020 · 3 comments
Closed

Cannot detect key presses that are handled by window manager #124

blokeley opened this issue May 4, 2020 · 3 comments

Comments

@blokeley
Copy link

blokeley commented May 4, 2020

Some key presses are handled by the Windows' window manager, such as Win+x.

Is it possible to:

  1. Detect those key presses?
  2. Prevent the window manager from processing them?

Example code: If a winit::event::DeviceEvent::Key is detected, pass it to the following function:

pub fn on_key_event(input: KeyboardInput) {
    if input.state != ElementState::Pressed {
        return;
    }
    println!("{:?} + {:?}", input.modifiers, input.virtual_keycode);
}
@blokeley blokeley changed the title Cannot detect state of Windows Key ("Logo" key) Cannot detect key presses that are handled by window manager May 4, 2020
@jdm
Copy link

jdm commented May 4, 2020

Did you mean to file this in https://github.com/rust-windowing/winit/?

@blokeley
Copy link
Author

blokeley commented May 4, 2020

I thought that it might be a Windows-specific issue so might only appear in winrt-rs. If it's a winit level limitation, please let me know and I'll consider filing an issue there. It may be related to the raw device events discussion.

@robmikh
Copy link
Member

robmikh commented May 4, 2020

Agreed, this seems to be a question directed at winit rather than Rust/WinRT.

FWIW, I'd advise against overriding system hotkeys. I also don't believe there's a way to prevent the system from receiving the keys. If you really need to detect the key-press for some reason, you should look into SetWindowsHookExW. However it won't stop the system from responding to it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants