User:Fred Gandt/stopChromeJumpingTheDamnTextboxOnEveryReturnPress.js
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$( document ).ready( () => {
"use strict";
const TB1 = document.getElementById( "wpTextbox1" );
if ( TB1 && TB1.style.display !== "none" ) {
TB1.addEventListener( "keydown", evt => {
if ( evt.key === "Enter" ) {
const SS = TB1.selectionStart;
evt.preventDefault();
TB1.value = TB1.value.substr( 0, SS ) + `
` + TB1.value.substr( TB1.selectionEnd );
TB1.setSelectionRange( SS + 1, SS + 1 );
}
} );
}
} );