From 19663e539ac3f1b9aed3257f939729cc4b7d0d08 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 30 Nov 2024 18:07:49 -0800 Subject: [PATCH] enh: temporary chat shortcut --- src/routes/(app)/+layout.svelte | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 6ce1612b7..72ae6229d 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -97,7 +97,7 @@ banners.set(await getBanners(localStorage.token)); tools.set(await getTools(localStorage.token)); - document.addEventListener('keydown', function (event) { + document.addEventListener('keydown', async function (event) { const isCtrlPressed = event.ctrlKey || event.metaKey; // metaKey is for Cmd key on Mac // Check if the Shift key is pressed const isShiftPressed = event.shiftKey; @@ -164,6 +164,18 @@ console.log('showShortcuts'); document.getElementById('show-shortcuts-button')?.click(); } + + // Check if Ctrl + Shift + ' is pressed + if (isCtrlPressed && isShiftPressed && event.key.toLowerCase() === `'`) { + event.preventDefault(); + console.log('temporaryChat'); + temporaryChatEnabled.set(!$temporaryChatEnabled); + await goto('/'); + const newChatButton = document.getElementById('new-chat-button'); + setTimeout(() => { + newChatButton?.click(); + }, 0); + } }); if ($user.role === 'admin' && ($settings?.showChangelog ?? true)) {