diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-12-14 07:04:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 07:04:17 +0000 |
commit | 96c393a7a77d8610abdba39197964be64eedef02 (patch) | |
tree | ba875cc4809910b1b5579248900fd89f4711a284 /script.js | |
parent | 09013b357ced9ec5f2772154054f7e544f99d8e0 (diff) | |
parent | 6513470f0db1aed1b0a5200634e8e02f7c05e932 (diff) | |
download | stable-diffusion-webui-gfx803-96c393a7a77d8610abdba39197964be64eedef02.tar.gz stable-diffusion-webui-gfx803-96c393a7a77d8610abdba39197964be64eedef02.tar.bz2 stable-diffusion-webui-gfx803-96c393a7a77d8610abdba39197964be64eedef02.zip |
Merge pull request #14269 from kaalibro/skip-interrupt-keyb-shortcuts
Add keyboard shortcuts for generate/skip/interrupt
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(); + } + } }); /** |