Possible Duplicate:
Bind textbox to 'enter' key
I've made a chat system with AJAX and jQuery and there is no <form>
tag wrapping the TextBox for chat messages, so I can't submit that message with the ENTER
button on the keyboard.
Is there any way I can submit that value from TextBox with javascript?
Thanks.
document.getElementById("id_of_your_textbox").addEventListener("keydown", function(e) {
if (!e) { var e = window.event; }
e.preventDefault(); // sometimes useful
// Enter is pressed
if (e.keyCode == 13) { submitFunction(); }
}, false);