I would like to add a button to my webpage, and when this button clicked, the console will open like what happens when the user click (F12) key on keyboard.
this is my try:
document.querySelector('#openConsole').addEventListener('click', () => {
var event = document.createEvent('Event');
event.initEvent('build', true, true);
event.keyCode = 123; // F12 key code
document.dispatchEvent(event);
});
<button id="openConsole">open console</button>
But it doesn't work!