From 6fedff44669849fead2154c096ef3118b2319b7a Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 28 Sep 2016 21:20:57 -0400 Subject: [PATCH] Don't allow the cursor to be moved --- main.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 3360899..8ba3f5d 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,13 @@ let editor = new CodeMirror(document.body, { value: "function myScript() {\t\n\treturn 100;\n}", mode: "javascript", readOnly: true, - autofocus: true + autofocus: true, + extraKeys: { + Up: () => {}, + Down: () => {}, + Left: () => {}, + Right: () => {} + } }); var incompleteMark = editor.doc.markText({ line: 0, ch: 0 }, getEndPos(), { @@ -18,6 +24,11 @@ editor.on("blur", (instance, event) => { focused = false; }) +editor.on("mousedown", (instance, event) => { + event.preventDefault(); + editor.focus(); +}); + let invalids = []; document.addEventListener("keypress", (event) => {