gpt4 book ai didi

javascript - 使用浏览器扩展程序在浏览器外捕获键盘快捷键?

转载 作者:行者123 更新时间:2023-11-30 10:15:36 25 4
gpt4 key购买 nike

我有一个项目需要一键通功能。我得出的结论是,如果我为 Chrome/Firefox 创建一个扩展/插件,它可能是可行的。该站点是基于 WebRTC 的 HTML5,我想实现一个可供用户下载的替代插件/扩展,这将允许他们在浏览器之外使用一键通。 IE。当浏览器最小化但网站仍在浏览器中打开时。

我希望插件/扩展仍然监听击键。这是可行的吗?或者我是否需要创建一个用户可以下载的应用程序,该应用程序将 Hook 到网站 webrtc API 并允许用户使用 Push-to-Talk?我宁愿远离必须下载 .exe 的用户,更希望他们能够为他们的 Chrome 或 Firefox 浏览器安装插件/扩展。

最佳答案

它在 Chrome 中原则上是可行的,因为你可以定义 global shortcuts with chrome.commands :

list :

"commands": {
"push-to-talk": {
"suggested_key": {
"default": "Ctrl+Shift+1"
},
"description": "Activate push-to-talk",
"global": true
}
},

背景:

chrome.commands.onCommand.addListener(function(command) {
if(command == "push-to-talk"){
// Do whatever you want, e.g. bring focus to browser,
// pass commands to page with content scripts etc.
}
});

关于javascript - 使用浏览器扩展程序在浏览器外捕获键盘快捷键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23919265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com