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"; | ||||
|   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(); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue