javascript - How does js trigger the keyboard Ctrl+P event by clicking a button?
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:29:30
0
1
595

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

过去多啦不再A梦
过去多啦不再A梦

reply all (1)
仅有的幸福
window.addEventListener('keydown', function (evt) { if (!evt.ctrlKey || (evt.key !== 'p' && evt.keyCode !== 80)) { return } evt.preventDefault() // .... window.print() })
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!