Skip to content

Groq Chat Focus Shortcut

Posted on:July 23, 2024 at 05:06 AM
// ==UserScript==
// @name         groq Chat Focus shortcut
// @namespace    Violentmonkey Scripts
// @version      1.0
// @description  Focuses the chat input field when 'Escape' is pressed.
// @author       cutbypham
// @match        https://groq.com/
// @grant        none
// ==/UserScript==

document.addEventListener("keydown", event => {
  if (event.key === "Escape") {
    const chatBox = document.querySelector(
      "div.hidden > div:nth-child(1) > div:nth-child(1) > form:nth-child(1) > div:nth-child(1) > textarea:nth-child(1)"
    );
    if (chatBox) {
      chatBox.focus();
    }
  }
});