From 263b5470614aa08a19a5a5605478b6da0d7552b8 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 25 Oct 2022 20:24:02 -0700 Subject: [PATCH] Use default behavior for modified clicks For example, Ctrl+Click should open in a new tab --- script.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script.js b/script.js index 0e9792c..14ae773 100644 --- a/script.js +++ b/script.js @@ -266,6 +266,10 @@ function route(href) { /* Set event handlers for client-side routing. */ globalThis.addEventListener('popstate', _ => showPage(location.pathname)); document.addEventListener('click', e => { + if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { + return; // Use default behavior if any keyboard modifier is applied to the click + } + const anchor = e.target.closest('a'); if (anchor) { e.preventDefault(); -- 2.47.3