Skip to content

Commit c359fc4

Browse files
author
ComputelessComputer
committed
enter to submit form
1 parent 6694f52 commit c359fc4

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/pages/index.astro

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ font-weight: 500;
7575
position: relative;
7676
top: -2px;
7777
}
78+
.contact-section .btn.pressed {
79+
transform: translateY(2px);
80+
box-shadow: 0 0 0 #c0c0c0;
81+
}
7882
.contact-section input:focus {
7983
outline: none;
8084
}
@@ -124,6 +128,21 @@ font-weight: 500;
124128
nameInput?.addEventListener('input', () => handleInput(nameInput));
125129
emailInput?.addEventListener('input', () => handleInput(emailInput));
126130

131+
function submitChat() {
132+
updateChatLink();
133+
chatBtn.classList.add('pressed');
134+
setTimeout(() => {
135+
window.location.href = chatBtn.href;
136+
}, 100);
137+
}
138+
139+
emailInput?.addEventListener('keydown', (e) => {
140+
if (e.key === 'Enter') {
141+
e.preventDefault();
142+
submitChat();
143+
}
144+
});
145+
127146
// Initial resize
128147
resizeInput(nameInput);
129148
resizeInput(emailInput);

0 commit comments

Comments
 (0)