From: Ardis Lu Date: Wed, 26 Oct 2022 03:24:02 +0000 (-0700) Subject: Use default behavior for modified clicks X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=263b5470614aa08a19a5a5605478b6da0d7552b8;p=ardislu.dev Use default behavior for modified clicks For example, Ctrl+Click should open in a new tab --- 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();