June 2025
Beginner
817 pages
31h 30m
English
What you’ve probably wondered about JavaScript events like keyboard events (e.g., a keystroke) is whether it’s somehow possible to determine which key triggers an event. Yes, this is possible, and this information is even already provided as a property of the respective event.
Events are themselves objects that have a variety of properties and methods, which is a typical feature of JavaScript. More precisely, the event object gets passed to the function to be called. To access it, you must explicitly pass the event object to the function as the first parameter. Here’s a simple example that demonstrates this process:
...<h1>Properties of events</h1><p onmousedown="showPos(event)"
Read now
Unlock full access