From e706907e79592e4f67ca557f94841f6ab02a3a27 Mon Sep 17 00:00:00 2001 From: boxgaming <75969133+boxgaming@users.noreply.github.com> Date: Tue, 21 Mar 2023 12:05:37 -0500 Subject: [PATCH] added support for F5 (build) and F11 (share) when in IDE mode --- qbjs-ide.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/qbjs-ide.js b/qbjs-ide.js index aeefbc8..f17b8c5 100644 --- a/qbjs-ide.js +++ b/qbjs-ide.js @@ -45,6 +45,7 @@ async function init() { document.getElementById("gx-load-screen").style.display = "block"; } + // initialize the code editor editor = CodeMirror(document.querySelector("#code"), { lineNumbers: true, @@ -70,6 +71,23 @@ async function init() { } }); + // if IDE mode, capture the F5 event + if (appMode != "play" && appMode != "auto") { + window.addEventListener("keydown", function(event) { + // run + if (event.code == 'F5') { + event.preventDefault(); + runProgram(); + } + // compile + else if (event.code == 'F11') { + event.preventDefault(); + shareProgram(); + } + }); + } + + document.getElementsByClassName("CodeMirror-cursor")[0].innerHTML = " ";