我只有 1 个输入字段,我想注册 onChange 和 onKeyPress 事件来检测用户何时完成输入或按下 Enter 键。我只需要使用javascript。谢谢您的帮助。
我有:
var load = function (){
//I want to trigger this function when user hit Enter key.
}
document.getElementById('co').onchange=load; //works great
document.getElementById('co').onKeyPress=load;
//not sure how to detect when user press Enter
html
//no form just a single input field
<input type='text' id='co'>