James T James T - 2 years ago 151
HTML Question

jQuery: Prevent enter key

I am trying to prevent the enter key from being put into a textarea, but it doesn't seem to work.

$('#comment').keyup(function(event) {
if (event.text.charCodeAt() == '10') {

Answer Source

I have written little demonstration on jsfiddle.net, where you can try this code

Everybody has right answer :)


    if (event.keyCode === 10 || event.keyCode === 13) 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download