parent
f00eaa4d00
commit
77bd953da2
22
script.js
22
script.js
|
@ -123,23 +123,25 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
/**
|
/**
|
||||||
* Add a Ctrl (Alt) + Enter as a shortcut to start / restart a generation
|
* Add a Ctrl (Alt) + Enter as a shortcut to start / restart a generation
|
||||||
*/
|
*/
|
||||||
document.addEventListener('keydown', (e) => {
|
document.addEventListener('keydown', function(e) {
|
||||||
const isEnter = e.key === 'Enter' || e.keyCode === 13
|
const isEnter = e.key === 'Enter' || e.keyCode === 13;
|
||||||
const isModifierKey = e.metaKey || e.ctrlKey || e.altKey
|
const isModifierKey = e.metaKey || e.ctrlKey || e.altKey;
|
||||||
|
|
||||||
const interruptButton = get_uiCurrentTabContent().querySelector('button[id$=_interrupt]')
|
const interruptButton = get_uiCurrentTabContent().querySelector('button[id$=_interrupt]');
|
||||||
const generateButton = get_uiCurrentTabContent().querySelector('button[id$=_generate]')
|
const generateButton = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
|
||||||
|
|
||||||
if (isEnter && isModifierKey) {
|
if (isEnter && isModifierKey) {
|
||||||
if (interruptButton.style.display === 'block') {
|
if (interruptButton.style.display === 'block') {
|
||||||
interruptButton.click()
|
interruptButton.click();
|
||||||
setTimeout(() => generateButton.click(), 500)
|
setTimeout(function() {
|
||||||
|
generateButton.click();
|
||||||
|
}, 500);
|
||||||
} else {
|
} else {
|
||||||
generateButton.click()
|
generateButton.click();
|
||||||
}
|
}
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks that a UI element is not in another hidden element or tab content
|
* checks that a UI element is not in another hidden element or tab content
|
||||||
|
|
Loading…
Reference in New Issue