Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add more keyboard shortcuts

thecodrrfb21558872e8
diff --git a/apps/web/src/common/key-map.js b/apps/web/src/common/key-map.js
index 98a70433c..b1e75f392 100644
--- a/apps/web/src/common/key-map.js
+++ b/apps/web/src/common/key-map.js
@@ -1,5 +1,6 @@
import hotkeys from "hotkeys-js";
import { hashNavigate, navigate } from "../navigation";
+import { store as themestore } from "../stores/theme-store";
import { GlobalKeyboard } from "../utils/keyboard";
const KEYMAP = [
@@ -44,6 +45,69 @@ const KEYMAP = [
navigate("/search/notes");
},
},
+ {
+ keys: ["alt+n"],
+ description: "Go to Notes",
+ global: false,
+ action: (e) => {
+ e.preventDefault();
+ navigate("/");
+ },
+ },
+ {
+ keys: ["alt+b"],
+ description: "Go to Notebooks",
+ global: false,
+ action: (e) => {
+ e.preventDefault();
+ navigate("/notebooks");
+ },
+ },
+ {
+ keys: ["alt+f"],
+ description: "Go to Favorites",
+ global: false,
+ action: (e) => {
+ e.preventDefault();
+ navigate("/favorites");
+ },
+ },
+ {
+ keys: ["alt+t"],
+ description: "Go to Tags",
+ global: false,
+ action: (e) => {
+ e.preventDefault();
+ navigate("/tags");
+ },
+ },
+ {
+ keys: ["alt+d"],
+ description: "Go to Trash",
+ global: false,
+ action: (e) => {
+ e.preventDefault();
+ navigate("/trash");
+ },
+ },
+ {
+ keys: ["alt+s"],
+ description: "Go to Settings",
+ global: false,
+ action: (e) => {
+ e.preventDefault();
+ navigate("/settings");
+ },
+ },
+ {
+ keys: ["command+d", "ctrl+d"],
+ description: "Toggle dark/light mode",
+ global: true,
+ action: (e) => {
+ e.preventDefault();
+ themestore.get().toggleNightMode();
+ },
+ },
];
export function registerKeyMap() {
diff --git a/apps/web/src/utils/keyboard.js b/apps/web/src/utils/keyboard.js
index 19295f473..345c635c6 100644
--- a/apps/web/src/utils/keyboard.js
+++ b/apps/web/src/utils/keyboard.js
@@ -11,9 +11,9 @@ GlobalKeyboard.addEventListener = (name, handler) => {
GlobalKeyboard.removeEventListener = (name, handler) =>
KeyboardEventManager.unsubscribe(name, handler);
-window.addEventListener("keydown", (e) => {
- KeyboardEventManager.publish("keydown", e);
-});
+// window.addEventListener("keydown", (e) => {
+// // KeyboardEventManager.publish("keydown", e);
+// });
window.addEventListener("keyup", (e) => {
KeyboardEventManager.publish("keyup", e);