diff --git a/static/dream_web/index.js b/static/dream_web/index.js index 4d1fbe3778..2d2dce1452 100644 --- a/static/dream_web/index.js +++ b/static/dream_web/index.js @@ -154,6 +154,12 @@ async function generateSubmit(form) { } window.onload = () => { + document.querySelector("#prompt").addEventListener("keydown", (e) => { + if (e.key === "Enter" && !e.shiftKey) { + const form = e.target.form; + generateSubmit(form); + } + }); document.querySelector("#generate-form").addEventListener('submit', (e) => { e.preventDefault(); const form = e.target; @@ -180,6 +186,12 @@ window.onload = () => { console.error(e); }); }); + document.documentElement.addEventListener('keydown', (e) => { + if (e.key === "Escape") + fetch('/cancel').catch(err => { + console.error(err); + }); + }); if (!config.gfpgan_model_exists) { document.querySelector("#gfpgan").style.display = 'none';