Skip to content

Instantly share code, notes, and snippets.

@athurg
Created October 20, 2011 13:59
Show Gist options
  • Save athurg/1301205 to your computer and use it in GitHub Desktop.
Save athurg/1301205 to your computer and use it in GitHub Desktop.
用于检测回车键的Javascript代码
<script>
function cb(obj)
{
var div;
div = document.getElementById("adiv");
div.innerHTML=obj.name+" enter :";
if (event.keyCode==13)
div.innerHTML+="Return";
else
div.innerHTML+=event.keyCode;
}
</script>
<div id="adiv"></div>
<input name=i onkeypress=cb(this) />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment