📜  在 javascript 代码示例中的按键上添加事件

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

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

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

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

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