diff options
author | metamuffin <metamuffin@disroot.org> | 2022-09-11 10:19:16 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-09-11 10:19:16 +0200 |
commit | fb5faafbc91c7779a7cae88bfe16652be6220df2 (patch) | |
tree | 59f6d5b2e22705d2b0b3276a63681e638c60e258 /client-web/source/chat.ts | |
parent | d8059a5d8bc36fd473103c575925705b16f2398c (diff) | |
download | keks-meet-fb5faafbc91c7779a7cae88bfe16652be6220df2.tar keks-meet-fb5faafbc91c7779a7cae88bfe16652be6220df2.tar.bz2 keks-meet-fb5faafbc91c7779a7cae88bfe16652be6220df2.tar.zst |
keybinds
Diffstat (limited to 'client-web/source/chat.ts')
-rw-r--r-- | client-web/source/chat.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/client-web/source/chat.ts b/client-web/source/chat.ts index bafed73..70f8cd2 100644 --- a/client-web/source/chat.ts +++ b/client-web/source/chat.ts @@ -8,6 +8,7 @@ import { User } from "./user/mod.ts"; export class Chat extends OverlayUi { messages: HTMLElement controls: HTMLElement + send_el: HTMLInputElement constructor(public room: Room) { const send = document.createElement("input") @@ -20,6 +21,7 @@ export class Chat extends OverlayUi { super(ediv({ class: "chat" }, messages, controls)) this.messages = messages this.controls = controls + this.send_el = send send.onkeydown = (ev) => { if (ev.code == "Enter") { @@ -49,15 +51,9 @@ export class Chat extends OverlayUi { reader.readAsDataURL(blob); } } - document.body.addEventListener("keydown", ev => { - // TODO is there a proper solution? - if (ev.target instanceof HTMLInputElement && !(ev.target.type == "button")) return - if (ev.code == "Enter") { - this.shown = !this.shown - if (this.shown) send.focus() - ev.preventDefault() // so focused buttons dont trigger - } - }) + } + focus() { + this.send_el.focus() } send(msg: ChatMessage) { |