How do I input a character, with either JQuery or plain JavaScript, as if it had been typed?
I have a contenteditable
section, and am intercepting user input in order to replace certain characters (for example straight quotes with curly ones). I have the following JQuery to intercept a character, but am not sure of the best way to input the new character.
$('.editor').keypress(function(e) {
console.log(e.which);
if (e.which === 39) {
e.preventDefault();
// replace with curly quotes
}
});