diff --git a/client/src/pages/Student/JoinRoom/JoinRoom.tsx b/client/src/pages/Student/JoinRoom/JoinRoom.tsx index f0ac8d7..c458d61 100644 --- a/client/src/pages/Student/JoinRoom/JoinRoom.tsx +++ b/client/src/pages/Student/JoinRoom/JoinRoom.tsx @@ -111,6 +111,12 @@ const JoinRoom: React.FC = () => { webSocketService.submitAnswer(answerData); }; + const handleReturnKey = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && username && roomName) { + handleSocket(); + } + }; + if (isWaitingForTeacher) { return (
@@ -167,7 +173,8 @@ const JoinRoom: React.FC = () => { onChange={(e) => setRoomName(e.target.value)} placeholder="Numéro de la salle" sx={{ marginBottom: '1rem' }} - fullWidth + fullWidth={true} + onKeyDown={handleReturnKey} /> { onChange={(e) => setUsername(e.target.value)} placeholder="Nom d'utilisateur" sx={{ marginBottom: '1rem' }} - fullWidth + fullWidth={true} + onKeyDown={handleReturnKey} /> { }; + const handleReturnKey = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && email && password) { + login(); + } + }; return ( { onChange={(e) => setEmail(e.target.value)} placeholder="Adresse courriel" sx={{ marginBottom: '1rem' }} - fullWidth + fullWidth={true} + onKeyDown={handleReturnKey} // Add this line as well /> { onChange={(e) => setPassword(e.target.value)} placeholder="Mot de passe" sx={{ marginBottom: '1rem' }} - fullWidth + fullWidth={true} + onKeyDown={handleReturnKey} // Add this line as well />