<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Events</title>
</head>
<body>
<h1>Keydown Event</h1>
<p>Press a key on your keyboard</p>
<script>
document.addEventListener('keydown', function(){
alert(`the ${event.key} key was pressed`);
});
</script>
</body>
</html>
키보드 키 누르면 어떤 키가 눌렸는지 팝업창에 뜸!
'Programming > JavaScript' 카테고리의 다른 글
Linking a JavaScript File (0) | 2022.07.08 |
---|---|
Hello World! (0) | 2022.07.07 |
Window Resizing (0) | 2022.03.11 |
Capturing Scroll Events (0) | 2022.03.11 |
Mouseover, Mouseover Events: HTMLPreviousNext (0) | 2022.03.11 |