diff options
author | Sj-Si <sjw.jetty@gmail.com> | 2024-01-11 21:37:35 +0000 |
---|---|---|
committer | Sj-Si <sjw.jetty@gmail.com> | 2024-01-11 21:37:35 +0000 |
commit | 036500223de0a3caaa86360a8ad3ed301e4367b0 (patch) | |
tree | f05f0d5fc503d9c35d57bad077a5dab1dfd6569e /script.js | |
parent | 0726a6e12e85a37d1e514f5603acf9f058c11783 (diff) | |
parent | cb5b335acddd126d4f6c990982816c06beb0d6ae (diff) | |
download | stable-diffusion-webui-gfx803-036500223de0a3caaa86360a8ad3ed301e4367b0.tar.gz stable-diffusion-webui-gfx803-036500223de0a3caaa86360a8ad3ed301e4367b0.tar.bz2 stable-diffusion-webui-gfx803-036500223de0a3caaa86360a8ad3ed301e4367b0.zip |
Merge changes from dev
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(); + } + } }); /** |