From dc1df22a2bd0899b878d89d45f201dede1417ada Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 8 Jan 2024 23:23:55 -0300 Subject: [PATCH] Press Tab to switch between current tab and Parameters tab (#5210) --- js/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/main.js b/js/main.js index cd7e5068..60f4bf3b 100644 --- a/js/main.js +++ b/js/main.js @@ -37,6 +37,7 @@ document.querySelector(".header_bar").addEventListener("click", function(event) //------------------------------------------------ // Keyboard shortcuts //------------------------------------------------ +let previousTabId = 'chat-tab-button'; document.addEventListener("keydown", function(event) { // Stop generation on Esc pressed @@ -97,6 +98,19 @@ document.addEventListener("keydown", function(event) { document.getElementById("Impersonate").click(); } + // Switch between tabs on Tab + else if (!event.ctrlKey && !event.shiftKey && event.key === "Tab") { + event.preventDefault(); + var parametersButton = document.getElementById('parameters-button'); + var parentContainer = parametersButton.parentNode; + var selectedChild = parentContainer.querySelector('.selected'); + if (selectedChild.id == 'parameters-button') { + document.getElementById(previousTabId).click(); + } else { + previousTabId = selectedChild.id; + parametersButton.click(); + } + } }); //------------------------------------------------