Possible Duplicate:
Javascript capture key
I'm working on reply function using mysql and php.
My MySQL db:
reply:
rid - id;
topicid - under which topic;
uid - id of the guy who replies;
content - what did the guy said.
Here's my html code:
<form id="replyform">
<textarea name="rplcont" placeholder="Press enter to submit your reply."><textarea>
</form>
My question is: How do I know if enter button is pressed?
Many thanks.
/----------------------------------------------/
here's my codes that work:
html:
<textarea id="reply" name="reply" onKeyPress="enterpressalert(event, this)"></textarea>
js:
function enterpressalert(e, textarea){
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
alert('enter press');
}
}
and it works.
Thanks for everyone who concerns this topic!
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
alert('enter press');
}