feat: add global shortcuts

This commit is contained in:
Xylight committed 2024-07-19 18:14:16 -07:00
1 parent f63db02e98
commit 98a597c0d3
2 files changed
+22 -2

No files matched your search

@@ -66,7 +66,7 @@
{
name: $t('nav.commands.main'),
actions: [
{ href: '/', name: $t('nav.home'), icon: Home },
{ href: '/', name: $t('nav.home'), icon: Home, shortcut: 'h' },
{ href: '/communities', name: $t('nav.communities'), icon: GlobeAlt },
],
},
@@ -82,6 +82,7 @@
href: '/inbox',
name: $t('profile.inbox'),
icon: Inbox,
shortcut: 'i',
},
{
href: '/saved',
@@ -216,6 +217,20 @@
togglePalette()
}
if (event.ctrlKey) {
const actions = groups
.flatMap((g) => g.actions)
.filter((a) => a.shortcut != undefined)
actions.forEach((a) => {
if (event.key === a.shortcut) {
event.preventDefault()
if (a.href) goto(a.href)
if (a.handle) a.handle()
}
})
}
if (!open) return
switch (event.key) {