From f0be285b3e1d34d259e90282cc4d2b92e91cfb72 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Fri, 24 May 2019 16:38:08 -0600 Subject: [PATCH] Enable login when pressing enter on fields --- src/js/account/render.js | 4 ++-- src/js/account/setupListeners.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/js/account/render.js b/src/js/account/render.js index c2b0730..38f2d92 100644 --- a/src/js/account/render.js +++ b/src/js/account/render.js @@ -18,7 +18,7 @@ export function renderLoginForm() {
- Log In
+
Forgot Password?
@@ -42,7 +42,7 @@ export function renderLoginForm() {
- Create Account +
diff --git a/src/js/account/setupListeners.js b/src/js/account/setupListeners.js index f17816b..60670d4 100644 --- a/src/js/account/setupListeners.js +++ b/src/js/account/setupListeners.js @@ -10,6 +10,30 @@ export function setupLoginModal(modal) { }); }); + [ + document.getElementById('loginEmail'), + document.getElementById('loginPassword'), + ].forEach(field => { + field.addEventListener('keydown', event => { + if (['Enter', 'Return'].includes(event.key)) { + logIn(); + } + }); + }); + + [ + document.getElementById('createNewEmail'), + document.getElementById('createNewPassword'), + document.getElementById('createNewConfirm'), + document.getElementById('createNewPublicName'), + ].forEach(field => { + field.addEventListener('keydown', event => { + if (['Enter', 'Return'].includes(event.key)) { + createAccount(); + } + }); + }); + document.getElementById('loginSubmit').addEventListener('click', logIn); document.getElementById('createAccountSubmit').addEventListener('click', createAccount); }