diff --git a/frontend/background.js b/frontend/background.js index 43c6832..9e3c132 100644 --- a/frontend/background.js +++ b/frontend/background.js @@ -40,3 +40,13 @@ chrome.runtime.onMessage.addListener((request, _, sendResponse) => { return true; } }); +//Default commmand = Alt+T , Mac = Option+T +chrome.commands.onCommand.addListener((command) => { + if (command === "translate") { + chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { + if (tabs.length > 0) { + chrome.tabs.sendMessage(tabs[0].id, { type: "ENABLE_PICKER" }); + } + }); + } +}); diff --git a/frontend/manifest.json b/frontend/manifest.json index b9827f2..daf9b1c 100644 --- a/frontend/manifest.json +++ b/frontend/manifest.json @@ -38,5 +38,14 @@ "resources": ["packages/prism.css"], "matches": [""] } - ] + ], + "commands": { + "translate": { + "suggested_key": { + "default": "Alt+Shift+A", + "mac": "Alt+Shift+A" + }, + "description": "Translate selected text" + } + } }