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
| Event | Occurs When |
|---|---|
| onkeydown | A user presses a key |
| onkeypress | A user presses a key |
| onkeyup | A user releases a key |
Window Event Attributes
Events triggered for the window object (applies to the <body> tag):
| Attribute | Value | Description |
|---|---|---|
| onafterprint | script | Script to be run after the document is printed |
| onbeforeprint | script | Script to be run before the document is printed |
| onbeforeunload | script | Script to be run when the document is about to be unloaded |
| onerror | script | Script to be run when an error occurs |
| onhashchange | script | Script to be run when there has been changes to the anchor part of the a URL |
| onload | script | Fires after the page is finished loading |
| onmessage | script | Script to be run when the message is triggered |
| onoffline | script | Script to be run when the browser starts to work offline |
| ononline | script | Script to be run when the browser starts to work online |
| onpagehide | script | Script to be run when a user navigates away from a page |
| onpageshow | script | Script to be run when a user navigates to a page |
| onpopstate | script | Script to be run when the window's history changes |
| onresize | script | Fires when the browser window is resized |
| onstorage | script | Script to be run when a Web Storage area is updated |
| onunload | script | Fires once a page has unloaded (or the browser window has been closed) |
Comments
Post a Comment