Hugo Add . Keyboard Shortcut

I read a post, like the idea of press . then take me to the edit page. I made some modifications to the code, here is mine:

  window.addEventListener("keypress", (event) => {
    const isEditKey = event.key === ".";
    const isHomePage = window.location.pathname === "/";
    const isPostsPage = window.location.pathname === "/posts/";
    const isTagsPage = window.location.pathname.startsWith("/tags/");

    const isInputOrTextArea =
      event.target.nodeName === "INPUT" || event.target.nodeName === "TEXTAREA";

    if (
      isEditKey &&
      !isHomePage &&
      !isPostsPage &&
      !isTagsPage &&
      !isInputOrTextArea
    ) {
      const contentPath = window.location.pathname.split("/");
      const fileName =
        contentPath.length === 3
          ? `${contentPath[contentPath.length - 2]}.org`
          : `posts/${contentPath[contentPath.length - 2]}.org`;
      const editUrl = `https://github.com/tianheg/blog/edit/main/content/${fileName}`;
      window.location.href = editUrl;
    }
  });
欢迎通过「邮件」或者点击「这里」告诉我你的想法
Welcome to tell me your thoughts via "email" or click "here"