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:
parent
e98b759446
commit
15466c9007
1 changed files with 5 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue