<form id="search-form" >
      <input type="text"  onkeypress="getKey();return false;"  name="keyword" placeholder="搜索明星名称"/>
      <button type="button" onclick="changeKeyword();">搜索</button>
</form> 
   function getKey(){ //网页内按下回车触发
          if(event.keyCode==13)
          {
          changeKeyword(); 
        }
   } 
在搜索栏里面输入内容后,按回车键执行搜索功能。 注意:在onkeypress函数 后面要加上return false 以屏蔽form表单自己默认的提交行为。
原文:http://www.cnblogs.com/qianxinxu/p/5615089.html