0
I’m hoping that when a person presses the button shift a tab opens and the previous one closes, but I’m not getting.
<script>
function keyCode(event) {
var x = event.keyCode;
var y = event.keyCode;
if (x == 16) { // 16 is the Shift key
window.open('https://google.com' , '_blank')
Window.close();
}
}
</script>
But only opens and does not close the previous.
By default, most browsers do not allow scripts close user-opened pages for security reasons. Note that when trying to use the function
close, a message of the typeScripts may close only the windows that were opened by it.appears in the console. Only pages opened through script, with the functionopen, can be closed. Read more on W3C specification.– Woss
But I tested your script and did not open anything in Chome, IE, Rdge, Firefox and Safari.
– user60252