Skip to content

Commit c6e82b1

Browse files
committed
#241 - Added keyboard shortcuts for 'New Note' and 'Go Home'
1 parent 430d676 commit c6e82b1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

client/App.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<script setup>
2020
import Mousetrap from "mousetrap";
21+
import "Mousetrap/plugins/global-bind/mousetrap-global-bind";
2122
import { useToast } from "primevue/usetoast";
2223
import { computed, ref } from "vue";
2324
import { RouterView, useRoute } from "vue-router";
@@ -30,6 +31,7 @@ import NavBar from "./partials/NavBar.vue";
3031
import SearchModal from "./partials/SearchModal.vue";
3132
import { loadStoredToken } from "./tokenStorage.js";
3233
import LoadingIndicator from "./components/LoadingIndicator.vue";
34+
import router from "./router.js";
3335
3436
const globalStore = useGlobalStore();
3537
const isSearchModalVisible = ref(false);
@@ -46,6 +48,22 @@ Mousetrap.bind("/", () => {
4648
}
4749
});
4850
51+
// 'CTRL/CMD + SHIFT + N' to create new note
52+
Mousetrap.bindGlobal("mod+shift+n", () => {
53+
if (route.name !== "login") {
54+
router.push({ name: "new" });
55+
return false;
56+
}
57+
});
58+
59+
// 'CTRL/CMD + SHIFT + H' to go to home
60+
Mousetrap.bindGlobal("mod+shift+h", () => {
61+
if (route.name !== "login") {
62+
router.push({ name: "home" });
63+
return false;
64+
}
65+
});
66+
4967
getConfig()
5068
.then((data) => {
5169
globalStore.config = data;

0 commit comments

Comments
 (0)