Control P simulation by code

Is there a way I can code the simulation of keystroke of Control P (for printing a page)? I want to user to press a button instead of pressing Control P.

Please take this post as reference: javascript - how to cancel window.print(); on click on the Print button, Print pop up but no print action - Stack Overflow

You might need to do modification, and this code is required to place in the Custom Code under wix settings. Not your editor code window.

Or this post: