Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  3] [ 3]  / answers: 1 / hits: 104624  / 12 Years ago, thu, january 10, 2013, 12:00:00

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!


More From » enter

 Answers
28
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
alert('enter press');
}

[#80969] Wednesday, January 9, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
haylie

Total Points: 26
Total Questions: 108
Total Answers: 104

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
;