This example uses the addEventListener() method to attach a "beforeprint" event to the window object.
Tip: The keyboard shortcut Ctrl+P prints a page.