simple-translate/src/common/getShortcut.js

24 lines
730 B
JavaScript
Raw Normal View History

2019-02-20 11:36:57 +00:00
import browserInfo from "browser-info";
import manifest from "src/manifest-firefox.json";
export default commandId => {
const suggestedKeys = manifest.commands[commandId].suggested_key || null;
if (!suggestedKeys) return null;
const os = browserInfo().os;
switch (os) {
case "Windows":
return suggestedKeys.windows || suggestedKeys.default;
case "OS X":
return suggestedKeys.mac || suggestedKeys.default;
case "Linux":
return suggestedKeys.linux || suggestedKeys.default;
case "Android":
return suggestedKeys.android || suggestedKeys.default;
case "iOS":
return suggestedKeys.ios || suggestedKeys.default;
default:
return suggestedKeys.default || null;
}
};