Compare commits

..

1 Commits

Author SHA1 Message Date
Charlotte Som 20fecd6891 Focus the chat whenever a button is pressed anywhere 2021-12-24 00:42:17 +00:00
2 changed files with 11 additions and 5 deletions

View File

@ -43,6 +43,15 @@ export const setupChat = async (socket) => {
document.querySelector("#chatbox-container").style["display"] = "block";
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();
window.addEventListener("resize", () => {
fixChatSize();

View File

@ -86,7 +86,6 @@ const setupOutgoingEvents = (video, socket) => {
video.addEventListener("pause", async (event) => {
if (outgoingDebounce || !video.controls) {
event.preventDefault();
return;
}
@ -108,7 +107,6 @@ const setupOutgoingEvents = (video, socket) => {
video.addEventListener("play", (event) => {
if (outgoingDebounce || !video.controls) {
event.preventDefault();
return;
}
@ -132,7 +130,6 @@ const setupOutgoingEvents = (video, socket) => {
}
if (outgoingDebounce || !video.controls) {
event.preventDefault();
return;
}