feat(index): add link keyboard shortcuts
All checks were successful
build dist / build-dist (push) Successful in 27s

This commit is contained in:
z0x 2025-04-18 11:53:51 -04:00
parent 11a4ca7c3b
commit 440682f6de
2 changed files with 28 additions and 4 deletions

View file

@ -12,3 +12,27 @@ animate(
ease: "easeIn",
},
);
document.addEventListener("keydown", ({ key }: KeyboardEvent) => {
const shortcuts: Record<string, string> = {
g: "a.git",
b: "a.blog",
m: "a.matrix",
};
const link = document.querySelector(
shortcuts[key.toLowerCase()] || "",
) as HTMLAnchorElement | null;
if (!link?.href) return;
const a = Object.assign(document.createElement("a"), {
href: link.href,
target: link.target,
rel: link.rel,
style: "display: none",
});
document.body.append(a);
a.click();
a.remove();
});