From 15466c9007df170493aafd3080b055f91fb54b05 Mon Sep 17 00:00:00 2001 From: ddaza Date: Fri, 15 May 2020 16:00:31 -0500 Subject: improve chat example (#5474) --- std/examples/chat/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'std/examples') diff --git a/std/examples/chat/index.html b/std/examples/chat/index.html index b26a4a15d..2daf288b3 100644 --- a/std/examples/chat/index.html +++ b/std/examples/chat/index.html @@ -29,10 +29,14 @@ connectButton.onclick=connect; const status = document.getElementById("status"); const input = document.getElementById("input"); + input.addEventListener("keydown", keyDownEvent); function send() { const msg = input.value; ws.send(msg); - applyState({inputValue: ""}) + applyState({inputValue: ""}); + } + function keyDownEvent(e) { + if (e.keyCode === 13) return send(); } function connect() { if (ws) ws.close(); -- cgit v1.2.3