Im trying to make a keycode to redirect users to new page in javascript, but my code is not working. Does anyone have a solution?
if (keyCode == 17&&65) {
window.location = "somerandompage.html";
}
Im trying to make a keycode to redirect users to new page in javascript, but my code is not working. Does anyone have a solution?
if (keyCode == 17&&65) {
window.location = "somerandompage.html";
}
It appears that you want it so that pressing Ctrl+a will redirect, which can be done by checking that a is pressed, and the Ctrl key is already pressed
window.addEventListener("keydown", event => {
if (event.keyCode === 65 && event.ctrlKey) {
alert("Ctrl+a pressed");
window.location = "somerandompage.html";
}
});