From b5942a90ea5a72e5ceeae614e542abb166249aef Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:04:39 -0600 Subject: [PATCH] typing indicator --- src/public/index.html | 17 +++++++++++++++++ src/server/message.go | 1 + 2 files changed, 18 insertions(+) diff --git a/src/public/index.html b/src/public/index.html index 677c5fb..9623c06 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -86,6 +86,8 @@ print(data.Text); } else if (data.QuietText) { print(data.QuietText); + } else if (data.Typing) { + print("(someone is typing...)") } } function ws_onerror(evt) { @@ -131,6 +133,21 @@ } return false; }; + + var typing_clear_timeout = 0; + input.onkeyup = function() { + if (input.value) { + if (!typing_clear_timeout) { + ws.send(`{"Typing":true}`); + } else { + clearTimeout(typing_clear_timeout); + } + typing_clear_timeout = setTimeout(() => { + ws.send(`{"Typing":false}`); + typing_clear_timeout = 0; + }, 3000); + } + }; });