Skip to content

derhuerst/window-on-print

Repository files navigation

window-on-print

Reliably detect when the user prints. A better solution for beforeprint/afterprint.

npm version build status dependency status dev dependency status ISC-licensed support me on Patreon

Installing

npm install window-on-print

Usage

const onPrint = require('window-on-print')

const unsubscribe = onPrint.before(window, () => {
	console.info('user is going to print')
})
onPrint.after(window, () => {
	console.info('user is has printed or aborted')
})

You may call unsubscribe() to stop listening for events.

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.