Javascript Window and Keyboard Event

 


Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body onresize = "display()">
    <h1>Javascript Keyboard & Window Event</h1>
    <!-- <button onkeyup = "display()">Keyboard : Event : Click ME</button> -->
    <script>
        function display(){
            alert("Hi, Event was triggered")
        }
    </script>
</body>
</html>

The KeyboardEvent Object handles events that occur when a user presses a key on the keyboard.

Keyboard Events

EventOccurs When
onkeydownA user presses a key
onkeypressA user presses a key
onkeyupA user releases a key




Window Event Attributes

Events triggered for the window object (applies to the <body> tag):

AttributeValueDescription
onafterprintscriptScript to be run after the document is printed
onbeforeprintscriptScript to be run before the document is printed
onbeforeunloadscriptScript to be run when the document is about to be unloaded
onerrorscriptScript to be run when an error occurs
onhashchangescriptScript to be run when there has been changes to the anchor part of the a URL
onloadscriptFires after the page is finished loading
onmessagescriptScript to be run when the message is triggered
onofflinescriptScript to be run when the browser starts to work offline
ononlinescriptScript to be run when the browser starts to work online
onpagehidescriptScript to be run when a user navigates away from a page
onpageshowscriptScript to be run when a user navigates to a page
onpopstatescriptScript to be run when the window's history changes
onresizescriptFires when the browser window is resized
onstoragescriptScript to be run when a Web Storage area is updated
onunloadscriptFires once a page has unloaded (or the browser window has been closed)

Comments

Popular posts from this blog

Javascript Array Concat and Join Method

JavaScript While Loop

JavaScript pop() Method