To Lecture Notes

IT 238 -- May 4, 2026

Review Exercises

  1. Write a script to test the keyup and keydown events. Use the DOM Keyboard Event property key, which shows which key was pressed. Answer:
    <!DOCTYPE html>
    
    <-- KeyDown Example
        Source code file: index.html -->
    
    <html lang="en"l>
    <head>
        <meta charset="UTF-8">
        <title>Test KeyPress</title>
        <script>
        function keyDownListener(e) {
            var para1 = document.getElementById("p1");
            para1.innerHTML += "keydown Event. Key " +  e.key + " was pressed<br>";
        }
        function init( ) {
            var textField1 = document.getElementById("tf1");
            textField1.addEventListener("keypress", keyDownListener);
        }
        window.addEventListener("load", init);
        </script>
    </head>
    <body>
        <h1>Test KeyPress</h1>
    
        <input type="text" id="tf1"><br><br>
    
        <label for="p1">Event Log:</label><br>
        <p id="p1"></p>
    
    </body>
    </html>
    
  2. Look up some of the other Keyboard events on the W3Schools website:
    https://www.w3schools.com/js/js_events_keyboard.asp

Classes

Project 3

Practice Problem

Review of CSS Selectors

The DOM