Is event object and window.event object the same ?

Hello guys, sorry to disturb you, can someone explain what is the difference between an event object passed by an event handler and an a window event please. I just read that the window.event was used for backward compatibility like this: event = event || window.event I don't understand, event and window.event aren't the same thing ? for e,g consider the following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event vs window.event</title>
</head>
<body>
<button id="clickMe">Click Me</button>
<input id="typeHere" placeholder="Type something here" />
<script>
// Click Event Listener
document.getElementById("clickMe").addEventListener("click", (event) => {
console.log("---- Click Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});

// Input Event Listener
document.getElementById("typeHere").addEventListener("input", (event) => {
console.log("---- Input Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event vs window.event</title>
</head>
<body>
<button id="clickMe">Click Me</button>
<input id="typeHere" placeholder="Type something here" />
<script>
// Click Event Listener
document.getElementById("clickMe").addEventListener("click", (event) => {
console.log("---- Click Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});

// Input Event Listener
document.getElementById("typeHere").addEventListener("input", (event) => {
console.log("---- Input Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});
</script>
</body>
</html>
I didn't really understand what is the difference
4 Replies
ἔρως
ἔρως2mo ago
just forget that that exists it should be the same, but there's nothing to guarantee it seriously, pretend that window.event doesnt exist and dont touch that deprecated "feature"
Faker
FakerOP2mo ago
ok ok 😂
Jochem
Jochem2mo ago
yeah, my first reaction was "oh yeah, window.event exists. huh"
ἔρως
ἔρως2mo ago
that, and focused and links and forms i think there's frames too

Did you find this page helpful?