📌  相关文章
📜  在 javascript 代码示例中添加事件侦听器按键事件

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

代码示例1
let msg = document.getDocumentById('#message');

msg.addEventListener("keydown", (event) => {
    // handle keydown
});

msg.addEventListener("keypress", (event) => {
    // handle keypress
});

msg.addEventListener("keyup", (event) => {
    // handle keyup
});