mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #13644 from XpucT/dev
Start / Restart generation by Ctrl (Alt) + Enter
This commit is contained in:
commit
861cbd5636
24
script.js
24
script.js
@ -124,16 +124,20 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
* Add a ctrl+enter as a shortcut to start a generation
|
* Add a ctrl+enter as a shortcut to start a generation
|
||||||
*/
|
*/
|
||||||
document.addEventListener('keydown', function(e) {
|
document.addEventListener('keydown', function(e) {
|
||||||
var handled = false;
|
const isEnter = e.key === 'Enter' || e.keyCode === 13;
|
||||||
if (e.key !== undefined) {
|
const isModifierKey = e.metaKey || e.ctrlKey || e.altKey;
|
||||||
if ((e.key == "Enter" && (e.metaKey || e.ctrlKey || e.altKey))) handled = true;
|
|
||||||
} else if (e.keyCode !== undefined) {
|
const interruptButton = get_uiCurrentTabContent().querySelector('button[id$=_interrupt]');
|
||||||
if ((e.keyCode == 13 && (e.metaKey || e.ctrlKey || e.altKey))) handled = true;
|
const generateButton = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
|
||||||
}
|
|
||||||
if (handled) {
|
if (isEnter && isModifierKey) {
|
||||||
var button = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
|
if (interruptButton.style.display === 'block') {
|
||||||
if (button) {
|
interruptButton.click();
|
||||||
button.click();
|
setTimeout(function() {
|
||||||
|
generateButton.click();
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
generateButton.click();
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user