From e55fbf675e5f0ed96f9d5f66052ddd48ddd25df1 Mon Sep 17 00:00:00 2001 From: dongchengjie <37543964+dongchengjie@users.noreply.github.com> Date: Thu, 20 Jun 2024 01:39:51 +0800 Subject: [PATCH] chore: disable shortcuts #1239 --- src/main.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 2b7b946..7d23368 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -31,15 +31,14 @@ if (!container) { document.addEventListener("keydown", (event) => { // Disable WebView keyboard shortcuts - if (["F5", "F7"].includes(event.key)) { - event.preventDefault(); - } - if ( - (event.ctrlKey || event.metaKey) && - ["F", "H", "P", "Q", "R", "U"].includes(event.key.toUpperCase()) - ) { - event.preventDefault(); - } + const disabledShortcuts = + ["F5", "F7"].includes(event.key) || + (event.altKey && ["ArrowLeft", "ArrowRight"].includes(event.key)) || + ((event.ctrlKey || event.metaKey) && + ["F", "G", "H", "J", "P", "Q", "R", "U"].includes( + event.key.toUpperCase() + )); + disabledShortcuts && event.preventDefault(); }); const contexts = [