documentaddEventListenerkeydown
document.addEventListener is a method of the Document interface in the Web Platform API that registers an event listener for events that occur within the document. It enables code to respond to user interactions and other events, even when they originate from elements nested inside the page. This is commonly used to handle clicks, key presses, or custom events at the document level, often as a form of event delegation.
Syntax and parameters: document.addEventListener(type, listener, options). The type is a string such as 'click', 'keydown', or
Event flow and handling: events originate at a target element and propagate through the DOM. If capture
Best practices: prefer a stable function reference for the listener to allow removal, limit document-level listeners