summaryrefslogtreecommitdiff
path: root/std/examples/chat
diff options
context:
space:
mode:
authorddaza <ddaza@users.noreply.github.com>2020-05-15 16:00:31 -0500
committerGitHub <noreply@github.com>2020-05-15 17:00:31 -0400
commit15466c9007df170493aafd3080b055f91fb54b05 (patch)
treeb7769a90ba7e588c896492d97f0d7b53104ddaeb /std/examples/chat
parente98b7594466b1cc3e7b328dda08a7326d211767c (diff)
improve chat example (#5474)
Diffstat (limited to 'std/examples/chat')
-rw-r--r--std/examples/chat/index.html6
1 files changed, 5 insertions, 1 deletions
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();