فهرست منبع

Add ctrl+enter as a shortcut to quickly start a generation.

Melan 2 سال پیش
والد
کامیت
6c36fe5719
1فایلهای تغییر یافته به همراه16 افزوده شده و 0 حذف شده
  1. 16 0
      script.js

+ 16 - 0
script.js

@@ -40,6 +40,22 @@ document.addEventListener("DOMContentLoaded", function() {
     mutationObserver.observe( gradioApp(), { childList:true, subtree:true })
     mutationObserver.observe( gradioApp(), { childList:true, subtree:true })
 });
 });
 
 
+/**
+ * Add a ctrl+enter as a shortcut to start a generation
+ */
+ document.addEventListener('keydown', function(e) {
+    var handled = false;
+    if (e.key !== undefined) {
+        if((e.key == "Enter" && (e.metaKey || e.ctrlKey))) handled = true;
+    } else if (e.keyCode !== undefined) {
+        if((e.keyCode == 13 && (e.metaKey || e.ctrlKey))) handled = true;
+    }
+    if (handled) { 
+        gradioApp().querySelector("#txt2img_generate").click(); 
+        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
  */
  */