]> git.ardis.lu - ardislu.dev/commitdiff
Use default behavior for modified clicks
authorArdis Lu <ardisglu@gmail.com>
Wed, 26 Oct 2022 03:24:02 +0000 (20:24 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 26 Oct 2022 03:24:02 +0000 (20:24 -0700)
For example, Ctrl+Click should open in a new tab

script.js

index 0e9792c68a914f52f44285f3614233f2fcfee028..14ae773b0208bd0f3f6e139f998f5085555595d5 100644 (file)
--- 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();
This page took 0.037281 seconds and 4 git commands to generate.