安装时如何在 chrome 扩展上强制使用键盘快捷键
How to force keyboard shortcut on chrome extension at install
我正在尝试实施 chrome 扩展程序,使用键盘快捷键触发事件。
快捷方式在此处声明:
"commands":{
"sample":{
"suggested_key" : {
"default":"Ctrl+I",
"windows":"Ctrl+I"
},
"description":"Refresh display",
"global": true
}
}
一切似乎都是合法的,但问题是我必须在 "Keyboard shortcut" Chrome 的菜单中手动设置我的键盘快捷键。
我必须在安装扩展程序时强制执行此操作,而无需手动设置。此扩展将用于我的自动机,他们无法手动设置。
我该怎么做?
您的描述无效,这就是它不会自动分配的原因。
关于全局快捷方式from documentation:
The user is free to designate any shortcut as global using the UI in chrome://extensions
\ Keyboard Shortcuts, but the extension developer is limited to specifying only Ctrl+Shift+[0..9]
as global shortcuts.
简而言之,你不能那样做;您需要更改使用的快捷方式或将其设为非全局。
自 2018 年 6 月起,Chrome/Chromium 发生了变化,要手动使用 change/assign 扩展快捷方式,您必须使用以下 URL:
chrome://extensions/shortcuts
对于扩展的制造商来说,JSON 也发生了一些变化,他们需要在 manifest.json
、manifest-GC.json
、manifest-MF.json
中添加快捷方式,如下所示:
"commands": { "execute_action": { "description": "Save Page", "suggested_key": { "default": "Alt+S" } },
"save_page": { "description": "Save Page", "suggested_key": { "default": "Alt+Down" } }
}
我正在尝试实施 chrome 扩展程序,使用键盘快捷键触发事件。
快捷方式在此处声明:
"commands":{
"sample":{
"suggested_key" : {
"default":"Ctrl+I",
"windows":"Ctrl+I"
},
"description":"Refresh display",
"global": true
}
}
一切似乎都是合法的,但问题是我必须在 "Keyboard shortcut" Chrome 的菜单中手动设置我的键盘快捷键。
我必须在安装扩展程序时强制执行此操作,而无需手动设置。此扩展将用于我的自动机,他们无法手动设置。
我该怎么做?
您的描述无效,这就是它不会自动分配的原因。
关于全局快捷方式from documentation:
The user is free to designate any shortcut as global using the UI in
chrome://extensions
\ Keyboard Shortcuts, but the extension developer is limited to specifying onlyCtrl+Shift+[0..9]
as global shortcuts.
简而言之,你不能那样做;您需要更改使用的快捷方式或将其设为非全局。
自 2018 年 6 月起,Chrome/Chromium 发生了变化,要手动使用 change/assign 扩展快捷方式,您必须使用以下 URL:
chrome://extensions/shortcuts
对于扩展的制造商来说,JSON 也发生了一些变化,他们需要在 manifest.json
、manifest-GC.json
、manifest-MF.json
中添加快捷方式,如下所示:
"commands": { "execute_action": { "description": "Save Page", "suggested_key": { "default": "Alt+S" } },
"save_page": { "description": "Save Page", "suggested_key": { "default": "Alt+Down" } }
}