Skip to content

Commit

Permalink
Adding some keyboard navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
tehaksbrid committed Dec 25, 2020
1 parent 61cf453 commit bfb6398
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ let show = (type) => {
Array.from(document.querySelectorAll(`.tab.${type},.content.${type}`)).forEach(el => el.classList.add('active'));
};

window.addEventListener('keydown', (ev) => {
if (ev.key === "1" && ev.ctrlKey === true) show("status");
else if (ev.key === "2" && ev.ctrlKey === true) show("stores");
else if (ev.key === "3" && ev.ctrlKey === true) show("queries");
else if (ev.key === "4" && ev.ctrlKey === true) show("settings");
else if (ev.key === "Tab") {
ev.preventDefault();
show("queries");
document.querySelector("textarea").focus();
}
});

class Status {
constructor() {
this.updateCallbacks = [];
Expand Down

0 comments on commit bfb6398

Please sign in to comment.