Keyboard Support

17 Feb 202214 minutes to read

The editor has full keyboard accessibility that includes shortcuts to open and other actions with toolbar items, drop-down lists, and dialogs.

HTML Formation Shortcut Key

You can use the following key shortcuts when the Rich Text Editor renders with HTML edit mode.

Actions Keyboard shortcuts
Toolbar focus `alt` + `f10`
Insert link `ctrl` + `k`
Insert image `ctrl` + `shift` + `i`
Insert table `ctrl` + `shift` + `e`
Undo `ctrl` + `z`
Redo `ctrl` + `y`
Copy `ctrl` + `c`
Cut `ctrl` + `x`
Paste `ctrl` + `v`
Bold `ctrl` + `b`
Italic `ctrl` + `i`
Underline `ctrl` + `u`
Strikethrough `ctrl` + `shift` + `s`
Uppercase `ctrl` + `shift` + `u`
Lowercase `ctrl` + `shift` + `l`
Superscript `ctrl` + `shift` + `=`
Subscript `ctrl` + `=`
Indents `ctrl` + `]`
Outdents `ctrl` + `[`
HTML source `ctrl` + `shift` + `h`
Fullscreen `ctrl` + `shift` + `f`
Exit Fullscreen `Esc`
Justify center `ctrl` + `e`
Justify full `ctrl` + `j`
Justify left `ctrl` + `l`
Justify right `ctrl` + `r`
Clear format `ctrl` + `shift` + `r`
Ordered list `ctrl` + `shift` + `o`
Unordered list `ctrl` + `alt` + `o`
@Html.EJS().RichTextEditor("keyboard").ContentTemplate(@<div>
    <p>
        The Rich Text Editor control is WYSIWYG ('what you see is what you get') editor that provides the best user experience to create and update the content.
        Users can format their content using standard toolbar commands.
    </p>
    <p><b> Key features:</b></p>
    <ul>
        <li><p> Provides &lt; IFRAME &gt; and &lt; DIV &gt; modes </p></li>

        <li><p> Capable of handling markdown editing.</p></li>

        <li><p> Contains a modular library to load the necessary functionality on demand.</p></li>

        <li><p> Provides a fully customizable toolbar.</p></li>

        <li><p> Provides HTML view to edit the source directly for developers.</p></li>

        <li><p> Supports third - party library integration.</p></li>

        <li><p> Allows preview of modified content before saving it.</p></li>

        <li><p> Handles images, hyperlinks, video, hyperlinks, uploads, etc.</p></li>

        <li><p> Contains undo / redo manager.</p></li>

        <li><p> Creates bulleted and numbered lists.</p></li>
    </ul>
</div>).Created("created").Height("500").ToolbarSettings(e => e.Items((object)ViewBag.items)).Render()

<script type="text/javascript">
    var rteObj;
    function created() {
        rteObj = document.getElementById("defaultRTE").ej2_instances[0];
    }
    document.addEventListener('keyup', function (e) {
        if (e.altKey && e.keyCode === 84) { /* t */
            // press alt+t to focus the control.
            rteObj.focusIn();
        }
    });
</script>
public class HomeController : Controller
{

    public ActionResult Index()
    {
        ViewBag.items = new[] { "Bold", "Italic", "Underline", "StrikeThrough",
        "FontName", "FontSize", "FontColor", "BackgroundColor",
        "LowerCase", "UpperCase", "|",
        "Formats", "Alignments", "OrderedList", "UnorderedList",
        "Outdent", "Indent", "|",
        "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "Print",
        "SourceCode", "FullScreen", "|", "Undo", "Redo"
    };
        return View();
    }
}

Markdown Formation Shortcut Key

You can use the following key shortcuts when the Rich Text Editor renders with Markdown edit mode.

Actions Keyboard shortcuts
Toolbar focus `alt` + `f10`
Insert link `ctrl` + `k`
Insert image `ctrl` + `shift` + `i`
Insert table `ctrl` + `shift` + `e`
Undo `ctrl` + `z`
Redo `ctrl` + `y`
Copy `ctrl` + `c`
Cut `ctrl` + `x`
Paste `ctrl` + `v`
Bold `ctrl` + `b`
Italic `ctrl` + `i`
Strikethrough `ctrl` + `shift` + `s`
Uppercase `ctrl` + `shift` + `u`
Lowercase `ctrl` + `shift` + `l`
Superscript `ctrl` + `shift` + `=`
Subscript `ctrl` + `=`
Fullscreen `ctrl` + `shift` + `f`
Ordered list `ctrl` + `shift` + `o`
Unordered list `ctrl` + `alt` + `o`
@using Syncfusion.EJ2.RichTextEditor

@Html.EJS().RichTextEditor("keyboard").EditorMode(EditorMode.Markdown).Value((string)ViewBag.value).Created("created").Height(300).ToolbarSettings(e => e.Items((object)ViewBag.items)).Render()

<script type="text/javascript">
    var rteObj;
    function created() {
        rteObj = this;
    }
    document.addEventListener('keyup', function (e) {
        if (e.altKey && e.keyCode === 84) { /* t */
            // press alt+t to focus the control.
            rteObj.focusIn();
        }
    });
</script>
public class HomeController : Controller
{

    public ActionResult Index()
    {
        ViewBag.items = new[] { "Bold", "Italic", "StrikeThrough", "|",
        "Formats", "OrderedList", "UnorderedList", "|",
        "CreateLink", "Image", "CreateTable", "|","Undo", "Redo" };

        ViewBag.value = @"The sample is added to showcase **markdown editing**.

    Type or edit the content and apply formatting to view markdown formatted content.

    We can add our own custom formation syntax for the Markdown formation.

    The third-party library <b>Marked</b> is used in this sample to convert markdown into HTML content";

        return View();
    }
}

Custom Key Config

Customize the key config for the keyboard interaction of Rich Text Editor, using the KeyConfig property.

In the following sample, customize the bold, italic, underline toolbar action with `ctrl` + `alt` + `b`, `ctrl` + `alt` + `i` and `ctrl` + `alt` + `u` respectively.

@Html.EJS().RichTextEditor("customKey").ContentTemplate(@<div>
    <p>
        The Rich Text Editor control is WYSIWYG ('what you see is what you get') editor that provides the best user experience to create and update the content.
        Users can format their content using standard toolbar commands.
    </p>
    <p><b> Key features:</b></p>
    <ul>
        <li><p> Provides &lt; IFRAME &gt; and &lt; DIV &gt; modes </p></li>

        <li><p> Capable of handling markdown editing.</p></li>

        <li><p> Contains a modular library to load the necessary functionality on demand.</p></li>

        <li><p> Provides a fully customizable toolbar.</p></li>

        <li><p> Provides HTML view to edit the source directly for developers.</p></li>

        <li><p> Supports third - party library integration.</p></li>

        <li><p> Allows preview of modified content before saving it.</p></li>

        <li><p> Handles images, hyperlinks, video, hyperlinks, uploads, etc.</p></li>

        <li><p> Contains undo / redo manager.</p></li>

        <li><p> Creates bulleted and numbered lists.</p></li>
    </ul>
</div>).KeyConfig((object)ViewBag.keyConfig).ToolbarSettings(e => e.Items((object)ViewBag.items)).Render()
public class HomeController : Controller
{
    public KeyModel KeyConfigData = new KeyModel();

    public class KeyModel
    {
        public string bold { get; set; }
        public string italic { get; set; }
        public string underline { get; set; }
    }
    public ActionResult Index()
    {
        KeyConfigData.bold = "ctrl+alt+b";
        KeyConfigData.italic = "ctrl+alt+i";
        KeyConfigData.underline = "ctrl+alt+u";

        ViewBag.keyConfig = KeyConfigData;

        ViewBag.items = new[] { "Bold", "Italic", "Underline", "StrikeThrough",
        "FontName", "FontSize", "FontColor", "BackgroundColor",
        "LowerCase", "UpperCase", "|",
        "Formats", "Alignments", "OrderedList", "UnorderedList",
        "Outdent", "Indent", "|",
        "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "Print",
        "SourceCode", "FullScreen", "|", "Undo", "Redo" };

        return View();
    }

}

See Also