function getKey(event) { if (event.keyCode == 13) { alert("我是回车键"); } }
<input type="password" onkeypress="getKey(event);"/>