feat: support the use of enter to submit on the login screen

This commit is contained in:
Zhang Minghan 2024-03-08 12:57:07 +08:00
parent 9916b45bc3
commit 15b7e204e1

View File

@ -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="" />