我只有1个输入字段,我想注册onChange和onKeyPress事件来检测用户何时完成输入或按Enter键。我只需要使用JavaScript。谢谢您的帮助。如何检测用户何时在输入字段中按Enter键
我:
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'>
的[在JavaScript中输入按键事件]可能的复制(http://stackoverflow.com/questions/905222/enter-key-press-event-in -javascript) – Bae 2016-03-23 21:16:14