-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyboardEvents.html
More file actions
31 lines (26 loc) · 919 Bytes
/
Copy pathkeyboardEvents.html
File metadata and controls
31 lines (26 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Keyboard Events</title>
</head>
<body>
<p id="p_one">Hello. Welcome to my web page</p>
<button id="btn_one" name="btn_one" class="btn_change" >Change Text</button>
<script>
var btn = document.getElementById("btn_one");
function changeText(event){
console.log(event);
var txt = document.getElementById("p_one");
txt.innerText = "This is a lesson in HTML DOM, Events and Events Listeners."
}
document.addEventListener("keydown", event => {
console.log("You have pressed: " + event.key);
});
document.addEventListener("keyup", event => {
console.log("You have released: " + event.key);
});
</script>
</body>
</html>