diff options
author | Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> | 2023-12-14 08:54:45 +0000 |
---|---|---|
committer | Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> | 2023-12-14 08:54:45 +0000 |
commit | 0fb34b57b80b368f76a368c50569371c10382e12 (patch) | |
tree | cb32ad64211ac1670bae87946190c85abd40773e /script.js | |
parent | 39ebd5684b377157eca7034feec4596707cfa9c7 (diff) | |
parent | aeaf1c510f1e7f246d892dad74122e0117a68a8c (diff) | |
download | stable-diffusion-webui-gfx803-0fb34b57b80b368f76a368c50569371c10382e12.tar.gz stable-diffusion-webui-gfx803-0fb34b57b80b368f76a368c50569371c10382e12.tar.bz2 stable-diffusion-webui-gfx803-0fb34b57b80b368f76a368c50569371c10382e12.zip |
Merge branch 'dev' into test-fp8
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -121,16 +121,22 @@ document.addEventListener("DOMContentLoaded", function() { }); /** - * Add a ctrl+enter as a shortcut to start a generation + * Add keyboard shortcuts: + * Ctrl+Enter to start/restart a generation + * Alt/Option+Enter to skip a generation + * Esc to interrupt a generation */ document.addEventListener('keydown', function(e) { const isEnter = e.key === 'Enter' || e.keyCode === 13; - const isModifierKey = e.metaKey || e.ctrlKey || e.altKey; + const isCtrlKey = e.metaKey || e.ctrlKey; + const isAltKey = e.altKey; + const isEsc = e.key === 'Escape'; - const interruptButton = get_uiCurrentTabContent().querySelector('button[id$=_interrupt]'); const generateButton = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); + const interruptButton = get_uiCurrentTabContent().querySelector('button[id$=_interrupt]'); + const skipButton = get_uiCurrentTabContent().querySelector('button[id$=_skip]'); - if (isEnter && isModifierKey) { + if (isCtrlKey && isEnter) { if (interruptButton.style.display === 'block') { interruptButton.click(); const callback = (mutationList) => { @@ -150,6 +156,21 @@ document.addEventListener('keydown', function(e) { } e.preventDefault(); } + + if (isAltKey && isEnter) { + skipButton.click(); + e.preventDefault(); + } + + if (isEsc) { + const globalPopup = document.querySelector('.global-popup'); + const lightboxModal = document.querySelector('#lightboxModal'); + if (!globalPopup || globalPopup.style.display === 'none') { + if (document.activeElement === lightboxModal) return; + interruptButton.click(); + e.preventDefault(); + } + } }); /** |