0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

improve chat example (#5474)

This commit is contained in:
ddaza 2020-05-15 16:00:31 -05:00 committed by GitHub
parent e98b759446
commit 15466c9007
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();