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

[feat] Allow listening for the release of a global shortcut's key combination #4364

Open
anoadragon453 opened this issue Jun 16, 2022 · 7 comments
Labels
status: backlog Issue is ready and we can work on it type: feature request

Comments

@anoadragon453
Copy link

Describe the problem

I would like to implement global push-to-talk functionality for voice calls in my app. I've seen the globalShortcut module which allows one to register a callback for when a key combination is pressed, even if the app is not in focus.

However, for effective push-to-talk, I would like to listen both for when the key combination is pressed, and when it is released. At the moment, the API only allows the former.

Describe the solution you'd like

I would like to be able to pass two callbacks to globalShortcut.register. The first would be called when the shortcut was pressed, and the second would be called when the shortcut was released.

Alternatives considered

An alternative is to have a single callback which is passed a boolean parameter, indicating whether the shortcut was pressed or released.

Additional context

No response

@DL-NEST
Copy link

DL-NEST commented Jul 1, 2022

`pub fn register_shortcuts(_app: &mut App) {
_app.global_shortcut_manager().register("Alt+D", my_custom_sys).expect("快捷键注册失败");
}

fn my_custom_sys() {
println!("global_shortcut:Alt+D");
}`
我想知道快捷键的回调如何获取app

@skyslide22
Copy link

I would also like to see this implemented in tauri, atm we have to do this on our own with f.e. https://docs.rs/device_query/0.1.3/device_query/index.html

@lucasfernog
Copy link
Member

/upstream tauri-apps/tao

@tauri-apps tauri-apps bot added the status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes label Jul 8, 2022
@tauri-apps
Copy link

tauri-apps bot commented Jul 8, 2022

Upstream issue at tauri-apps/tao#467 has been closed.

@tauri-apps tauri-apps bot added status: backlog Issue is ready and we can work on it and removed status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes labels Jul 8, 2022
@amrbashir
Copy link
Member

amrbashir commented Jul 8, 2022

The implementation of globalShortcut at least on Windows doesn't allow that (limitation of the used win32 API).

For this use-case, global keyboard events should be used with manual track of modifiers and key combos but for now global keyboard events doessn't work on Wayland (limitation of Wayland, they still wouldn't provide a protocol for it, even though many developers requested it) and flaky on X11?.

@felix307253927
Copy link

@amrbashir hotkey库使用的winapi可以监听到keydown和keyup事件,如果想要监听按键释放还要自己稍微改动下代码;
我在自己的程序中实现了监听按键按下和松开的功能,它可以在失去焦点时正常运行但是如果我把我的程序集成到tauri中时就会出问题;当tauri获取焦点时监听无效,当其他任何程序获得焦点时都可以正常监听到按键事件,我不知道tauri内部做了什么
image

@FabianLars
Copy link
Member

@felix307253927 Tauri v1.3 will have a method to disable the filter: #5562 - if you can't wait for that release, you can also use the dev branch as described here: https://tauri.app/v1/guides/faq#how-can-i-use-unpublished-tauri-changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backlog Issue is ready and we can work on it type: feature request
Projects
Status: 📬Proposal
Development

No branches or pull requests

7 participants