window.print(), this method can only be triggered after the page is completely loaded.
When the page loads slowly or when asynchronous JS is loaded, click the page print button to print. window.print() can only be triggered after the page loading is completed, so I want to notify JS to directly trigger Ctrl P implementation
仅有的幸福2017-05-19 10:31:30
window.addEventListener('keydown', function (evt) {
if (!evt.ctrlKey || (evt.key !== 'p' && evt.keyCode !== 80)) { return }
evt.preventDefault()
// ....
window.print()
})