Console updates (#99)

This commit is contained in:
Paulus Schoutsen 2021-11-10 17:07:01 -08:00 committed by GitHub
parent 971453d8a9
commit eb4ebfa17b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,14 +126,18 @@ export class EwtConsole extends HTMLElement {
<form>
>
<input autofocus>
<button type="button">Send</button>
</form>
`;
this._console = new ColoredConsole(this.shadowRoot!.querySelector("div")!);
const input = this.shadowRoot!.querySelector("input")!;
this.addEventListener("click", () => input.focus());
this.addEventListener("click", () => {
// Only focus input if user didn't select some text
if (getSelection()?.toString() === "") {
input.focus();
}
});
input.addEventListener("keydown", (ev) => {
if (ev.key === "Enter") {