區別:編碼不一樣
以下面以這段代碼示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" id="username">
<script>
username.onkeydown = function (e) {
console.log(e.keyCode);
}
username.onkeypress = function (e) {
console.log(e.keyCode);
}
</script>
</body>
</html>
輸出結果:
65
97
感謝觀看 期待關注
關注我,帶你一起寫bug
warning :未經授權,不得轉載
有問題的小夥伴請在下方留言,喜歡就點個贊吧