3
I have a textarea
out of a form:
<textarea name="textoOriginal">
Within that textarea
, I can type a text, and ENTER or SHIFT + ENTER for line breaking. When I take the value of the element, I need to differentiate what was ENTER and what was SHIFT + ENTER, but I receive all with ASCII code 10
Test I took:
Html:
<textarea class="form-control" name="textoOriginal" rows="15"></textarea>
Javascript:
document.querySelector('textarea[name="textoOriginal"').value.split('')
.forEach( function (value) {
console.log(value + ' corresponde a:'+value.charCodeAt(0));
});
Curiosity: what would be the application of this?
– Woss
The internal html generated for both cases is the same as the visual effect. Why differentiate in code?
– Isac
You can do this using the events: onkeydown onkeypress onkeyup
– Jose Marques