shift,entersimulatealt,enter,control,enter,altcontrolentershift

Kubilay 3/13/2017 0

This code block simulates shift enter event for editable divs, for alt+enter or control+enter events.

JavaScript
 function ShiftEnter() {
    var sel = window.getSelection();
    var fnode = sel.focusNode;
    var newNode = document.createElement("div");
    newNode.innerHTML = "<br>";
    var textNode = document.createTextNode('\u00A0');
    $(fnode).after(newNode);
    $(newNode).after(textNode);
    var range = document.createRange();
    range.selectNodeContents(textNode);
    range.collapse(true);
    sel.removeAllRanges();
    sel.addRange(range);
    $(newNode).after("<br>");
    $(newNode).remove();
    return true;
} 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments