📜  我如何在 javascript 代码示例中收听按键

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

代码示例1
let b = document.getElementById("body"); //making var for body
b.addEventListener("keydown", (evt) => {//when this happens
    console.log(evt.keyCode); //log keycode
});