I am trying to make a button which will toggle chrome developer/inspect tools. This may sound silly but I just want to know if it is possible to do.
btn = document.querySelector('#test')
btn.addEventListener('click', () => {
jQuery.event.trigger({ type : 'keypress', which : 123 });
console.log('open inspect window')
})
$('body').keypress(function(e) {
alert(e.which);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<button id='test'>Toggle Dev Tools</button>
I tried triggering f12 key which is an shortcut to dev tools, but it didn't work (i dunno why).
What I think is keypress won't work on function keys, therefore we need keydown which is working for some reason. I changed 'type' to 'keydown' instead of 'keypress'
If anyone could help or explain that would be really helpful