mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-03 10:50:23 +00:00
Add keyboard shortcuts for generation
(Removed Alt+Enter) Ctrl+Enter to start/restart generation (New) Alt/Option+Enter to skip generation (New) Ctrl+Alt/Option+Enter to interrupt generation
This commit is contained in:
23
script.js
23
script.js
@@ -121,16 +121,21 @@ 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
|
||||
* Alt/Option+Ctrl+Enter 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 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 && !isAltKey) {
|
||||
if (interruptButton.style.display === 'block') {
|
||||
interruptButton.click();
|
||||
const callback = (mutationList) => {
|
||||
@@ -150,6 +155,16 @@ document.addEventListener('keydown', function(e) {
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (isAltKey && isEnter && !isCtrlKey) {
|
||||
skipButton.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (isAltKey && isCtrlKey && isEnter) {
|
||||
interruptButton.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user