diff --git a/js/type.js b/js/type.js index d6424e1..e15f6e2 100644 --- a/js/type.js +++ b/js/type.js @@ -165,6 +165,9 @@ function handleKeyDown(event) { } else if (event.keyCode == 13) { // enter event.preventDefault(); handleEnter(event); + } else if (event.keyCode == 9) { // tab + event.preventDefault(); + handleTab(event); } } } @@ -225,6 +228,14 @@ function handleEnter(event) { } } +function handleTab(event) { + let pos = editor.getCursor(); + let line = editor.doc.getLine(pos.line); + if (line.charCodeAt(pos.ch) == 9) { + setCursor({ line: pos.line, ch: pos.ch + 1 }); + } +} + function moveToEndOfPreviousLine() { let pos = editor.getCursor(); if (pos.line > 0) {