Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start / Restart generation by Ctrl (Alt) + Enter #13644

Merged
merged 5 commits into from
Oct 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update script.js
Exclude lambda
  • Loading branch information
XpucT authored Oct 15, 2023
commit 77bd953da2f96845b196f242f7ba51138cd54e3b
22 changes: 12 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
@@ -123,23 +123,25 @@ document.addEventListener("DOMContentLoaded", function() {
/**
* Add a Ctrl (Alt) + Enter as a shortcut to start / restart a generation
*/
document.addEventListener('keydown', (e) => {
const isEnter = e.key === 'Enter' || e.keyCode === 13
const isModifierKey = e.metaKey || e.ctrlKey || e.altKey
document.addEventListener('keydown', function(e) {
const isEnter = e.key === 'Enter' || e.keyCode === 13;
const isModifierKey = e.metaKey || e.ctrlKey || 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 generateButton = get_uiCurrentTabContent().querySelector('button[id$=_generate]');

if (isEnter && isModifierKey) {
if (interruptButton.style.display === 'block') {
interruptButton.click()
setTimeout(() => generateButton.click(), 500)
interruptButton.click();
setTimeout(function() {
generateButton.click();
}, 500);
} else {
generateButton.click()
generateButton.click();
}
e.preventDefault()
e.preventDefault();
}
})
});

/**
* checks that a UI element is not in another hidden element or tab content