【发布时间】:2018-12-13 05:19:06
【问题描述】:
<input type="text" id= 'input'>
let input = document.getElementById('input');
//add event listener to keydown event
input.addEventListener('keydown',(e)=> {
console.log(e.key);
//check the key is 'Escape'
if( e.key === 'Escape') {
input.select();}
});
当我按“Esc”时,它不起作用,它只会模糊,不要选择我的 输入输入元素。我哪里弄错了?
【问题讨论】:
标签: javascript