commands 快捷键
允许用户设置和监听浏览器命令
权限与快捷键配置
{
"permissions": [
"commands"
],
"commands": {
"toggle-feature-foo": {
"suggested_key": {
"default": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y"
},
"description": "Toggle feature foo"
}
}
}
监听快捷键
// 监听快捷键
chrome.commands.onCommand.addListener((command) => {
console.log(`Command: ${command}`);
});