diff options
author | ddaza <ddaza@users.noreply.github.com> | 2020-05-15 16:00:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 17:00:31 -0400 |
commit | 15466c9007df170493aafd3080b055f91fb54b05 (patch) | |
tree | b7769a90ba7e588c896492d97f0d7b53104ddaeb /std/examples | |
parent | e98b7594466b1cc3e7b328dda08a7326d211767c (diff) |
improve chat example (#5474)
Diffstat (limited to 'std/examples')
-rw-r--r-- | std/examples/chat/index.html | 6 |
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(); |