Skip to content

Commit 3edcf13

Browse files
Merge pull request #28 from hemanth5055/feature/keyboard-shortcut-code-picker
Added keyboard shortcut for code selection
2 parents 9a76586 + 91a3f79 commit 3edcf13

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

frontend/background.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ chrome.runtime.onMessage.addListener((request, _, sendResponse) => {
4040
return true;
4141
}
4242
});
43+
//Default commmand = Alt+T , Mac = Option+T
44+
chrome.commands.onCommand.addListener((command) => {
45+
if (command === "translate") {
46+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
47+
if (tabs.length > 0) {
48+
chrome.tabs.sendMessage(tabs[0].id, { type: "ENABLE_PICKER" });
49+
}
50+
});
51+
}
52+
});

frontend/manifest.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,14 @@
3838
"resources": ["packages/prism.css"],
3939
"matches": ["<all_urls>"]
4040
}
41-
]
41+
],
42+
"commands": {
43+
"translate": {
44+
"suggested_key": {
45+
"default": "Alt+Shift+A",
46+
"mac": "Alt+Shift+A"
47+
},
48+
"description": "Translate selected text"
49+
}
50+
}
4251
}

0 commit comments

Comments
 (0)