📜  我想检测用户何时在输入文本中输入字母键 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:12.454000             🧑  作者: Mango

代码示例1
document.addEventListener('keyup', event => {
  if (String.fromCharCode(event.keyCode).match(/(\w|\s)/g)) {
    //pressed key is a char
  } else {
    //pressed key is a non-char
    //e.g. 'esc', 'backspace', 'up arrow'
  }
});