首先给input框添加onkeypress事件
<input type="text" id="serialNO" onkeypress="return onKeyPress(event)">
然后编写事件
function onKeyPress(e)
{
var keyCode = null;
if(e.which)
keyCode = e.which;
else if(e.keyCode)
keyCode = e.keyCode;
if(keyCode == 13)
{
SendMessage();
return false;
}
return true;
}