Skip to content

Commit

Permalink
feat: support the use of enter to submit on the login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Mar 8, 2024
1 parent 9916b45 commit 15b7e20
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/src/routes/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ function Login() {
}
};

useEffect(() => {
// listen to enter key and auto submit
const listener = async (e: KeyboardEvent) => {
if (e.key === "Enter") await onSubmit();
};

document.addEventListener("keydown", listener);
return () => document.removeEventListener("keydown", listener);
}, []);

return (
<div className={`auth-container`}>
<img className={`logo`} src={appLogo} alt="" />
Expand Down

0 comments on commit 15b7e20

Please sign in to comment.