Skip to content

Commit

Permalink
Add shortcut keys
Browse files Browse the repository at this point in the history
  • Loading branch information
wmstack committed Oct 26, 2024
1 parent a838039 commit 5cba979
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions toggle-bars/toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ Toggles = {
this.version = version;
this.rootURI = rootURI;
this.initialized = true;

// Zotero.getOSVersion().then((version) => {
// Toggles.macOs = version.includes("macOS");
// });
},

log(msg) {
Zotero.debug("Make It Red: " + msg);
Zotero.debug("Toggle-Bars: " + msg);
},

toggleListener(doc, key, toggle) {
doc.addEventListener('keydown', function(event) {
if ((event.ctrlKey) && event.key === key) {
toggle(doc);
}
});
},

addMenuItems(doc, manualPopup) {
Expand All @@ -36,6 +48,8 @@ Toggles = {
Toggles.toggleTabBar(doc);
});
viewPopup.appendChild(tab_bar_item);
// add shortcut key
Toggles.toggleListener(doc, "t", () => Toggles.toggleTabBar(doc));
this.storeAddedElement(tab_bar_item);

// Annotation Tool Bar Toggle
Expand All @@ -46,6 +60,7 @@ Toggles = {
Toggles.toggleAnnotation(annotation_tool_bar.checked);
});
viewPopup.appendChild(annotation_tool_bar);
Toggles.toggleListener(doc, "a", () => Toggles.toggleAnnotation());
this.storeAddedElement(annotation_tool_bar);

// Sidebar toggle
Expand All @@ -55,8 +70,8 @@ Toggles = {
side_bar_toggle.addEventListener('command', () => {
Toggles.toggleSidebar();
});

viewPopup.appendChild(side_bar_toggle);
Toggles.toggleListener(doc, "b", () => Toggles.toggleSidebar());
this.storeAddedElement(side_bar_toggle);
},

Expand Down Expand Up @@ -135,7 +150,7 @@ Toggles = {
Toggles.addToWindow(domWindow, true);
}, {once: true});
}
};
};

// Add the listener to detect new windows
Services.wm.addListener(windowListener);
Expand Down

0 comments on commit 5cba979

Please sign in to comment.