Keyboard Shortcuts

General Shortcuts (CTRL+Z,A,X,C,V,B,U,I) are supported in Rich Text Editor. You can also create your own keyboard shortcuts.

This demo shows how to create two shortcuts (CTRL+J and Ctrl+Down Arrow).

Example code

<div id="div_editor1"><p>This demo shows how to create two shortcuts (CTRL+J and Ctrl+Down Arrow).<p></div>
<script>
    var editor1 = new RichTextEditor("#div_editor1");
    editor1.document.addEventListener("keydown", function (e) {
        if (e.ctrlKey && e.key == 'j') {
            e.preventDefault();
            editor1.insertHTML("&nbsp;" + new Date().toString() + "&nbsp;");
            editor1.collapse(false);
        }
        if (e.ctrlKey && e.keyCode == 40) {//ArrowDown
            e.preventDefault();
            editor1.selectDoc(false);
            var p = editor1.insertRootParagraph("p");
            p.innerHTML = "<br/>";
            editor1.selectDoc(false);
        }
    })
</script>