Improve Login/Join/Manager Input

This commit is contained in:
Ralex91
2024-02-08 16:03:44 +01:00
parent 8493987f8e
commit 31122b9d2f
3 changed files with 22 additions and 0 deletions

View File

@@ -16,6 +16,12 @@ export default function Username() {
socket.emit("player:join", { username: username, room: player.room })
}
const handleKeyDown = (event) => {
if (event.key === "Enter") {
handleJoin()
}
}
useEffect(() => {
socket.on("game:successJoin", () => {
dispatch({
@@ -35,6 +41,7 @@ export default function Username() {
<Form>
<Input
onChange={(e) => setUsername(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="Usernname here"
/>
<Button onClick={() => handleJoin()}>Submit</Button>