Use the addEventListener() method to attach an "afterprint" event to the window object.
Tip: The keyboard shortcut Ctrl+P prints a page.