LARS FOCUS KEYBIND

Enables mouse-less navigation in Gemini Chats by implementing a simple keybind, which toggles focus on and off the input field (=> Bound to 'CTRL+SPACE' per default)

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         LARS FOCUS KEYBIND
// @namespace    http://tampermonkey.net/
// @version      2025-08-23
// @description  Enables mouse-less navigation in Gemini Chats by implementing a simple keybind, which toggles focus on and off the input field (=> Bound to 'CTRL+SPACE' per default)
// @author       larsFyzza, Google Gemini
// @match        https://gemini.google.com/app/*
// @match        https://gemini.google.com/app/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gemini.google.com
// @run-at       document-idle
// @grant        none
// @license      MIT:
// ==/UserScript==
//
//
//
// Works by calling element.focus() and element.blur().
// Most of this was written by Gemini, which is objectively funny.
// This is my first time publishing code and actually feeling like it's not *completely* unnecessary,
// because I was actually pretty annoyed with having to use my mouse for Gemini. With this: QoL imrpovement
// achieved.
//
//
// Regards,
// LARS!!!!!!!!!
//
//
//                       DEFINE KEYBIND HERE!!!!!
//                   ↙
const KEYBIND = {
    key: ' ',
    ctrlKey: true,
    altKey: false,
    shiftKey: false,
};



(function() {
    'use strict';
    console.log("LARS SCRIPT WURDE GELADEN! ICH WIEDERHOLE, LARS' SCRIPT HAT DEN DOM-TREE INFILTRIERT!!!!")
    function togglePromptFocus() {
        const promptField = document.querySelector('div.ql-editor.textarea[contenteditable="true"]');
        if (promptField) {
            // Check if the prompt field is already the active element
            if (document.activeElement === promptField) {
                // If it is, remove the focus
                promptField.blur();
                console.log("Unfocussed the prompt field.");
            } else {
                // If not, set the focus
                promptField.focus();
                console.log("Focussed the prompt field.");
            }
        } else {
            console.log("Focussable Element not found (Check the script's querySelector).");
        }
    }
    document.addEventListener('keydown', function(event) {
        if (event.key === KEYBIND.key && event.ctrlKey === KEYBIND.ctrlKey && event.altKey === KEYBIND.altKey && event.shiftKey === KEYBIND.shiftKey) {
            event.preventDefault();
            togglePromptFocus();
        }
    });
})();