Skip to content

Commit

Permalink
mod-enter to open in new tab (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock authored May 29, 2024
1 parent f80bbab commit c7b7ef7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/client/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ input.addEventListener("keydown", (event) => {
const results = resultsContainer.querySelector("ol");
if (!results) return;
let activeResult = results.querySelector(`.${activeClass}`);
if (code === "Enter") return activeResult.querySelector("a").click();
if (code === "Enter") {
const a = activeResult.querySelector("a");
if (/Mac|iPhone/.test(navigator.platform) ? event.metaKey : event.ctrlKey) open(a.href, "_blank");
else a.click();
return;
}
activeResult.classList.remove(activeClass);
if (code === "ArrowUp") activeResult = activeResult.previousElementSibling ?? results.lastElementChild;
else activeResult = activeResult.nextElementSibling ?? results.firstElementChild;
Expand Down

0 comments on commit c7b7ef7

Please sign in to comment.