I use preventDefault on space key, enter key, tab key's keydown event to prevent URL detection. Tested on IE11 and Chrome.
document.getElementById("input").addEventListener("keydown", function (e) {
var SPACEKEY = 32;
var ENTERKEY = 13;
var TABKEY = 9;
var whiteSpace = "";
if (e.keyCode == SPACEKEY || e.keyCode == ENTERKEY || e.keyCode == TABKEY) {
e.preventDefault();
if (e.keyCode == SPACEKEY) {
whiteSpace = " ";
} else if (e.keyCode == ENTERKEY) {
whiteSpace = "\n";
} else if (e.keyCode == TABKEY) {
whiteSpace = "\t";
}
var selection = document.getSelection();
var start = selection.anchorOffset > selection.focusOffset ? selection.focusOffset : selection.anchorOffset;
var end = selection.anchorOffset > selection.focusOffset ? selection.anchorOffset : selection.focusOffset;
$(this).text($(this).text().substring(0, start)
+ " "
+ $(this).text().substring(end));
var range = document.createRange();
range.setStart($(this)[0].firstChild, start + 1);
range.setEnd($(this)[0].firstChild, start + 1);
selection.removeAllRanges();
selection.addRange(range);
}
return false;
});