feat(index): add link keyboard shortcuts
All checks were successful
build dist / build-dist (push) Successful in 27s
All checks were successful
build dist / build-dist (push) Successful in 27s
This commit is contained in:
parent
11a4ca7c3b
commit
440682f6de
2 changed files with 28 additions and 4 deletions
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue