forked from forktown/watch-party
Focus the chat whenever a button is pressed anywhere
This commit is contained in:
parent
d446869a28
commit
20fecd6891
1 changed files with 9 additions and 0 deletions
|
@ -43,6 +43,15 @@ export const setupChat = async (socket) => {
|
||||||
document.querySelector("#chatbox-container").style["display"] = "block";
|
document.querySelector("#chatbox-container").style["display"] = "block";
|
||||||
setupChatboxEvents(socket);
|
setupChatboxEvents(socket);
|
||||||
|
|
||||||
|
window.addEventListener("keydown", event => {
|
||||||
|
try {
|
||||||
|
const isSelectionEmpty = window.getSelection().toString().length === 0;
|
||||||
|
if (event.code.match(/Key\w/) && isSelectionEmpty)
|
||||||
|
document.querySelector("#chatbox-send > input").focus()
|
||||||
|
} catch (_err) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fixChatSize();
|
fixChatSize();
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
fixChatSize();
|
fixChatSize();
|
||||||
|
|
Loading…
Reference in a new issue