document.addEventListener('keydown', (event) => {
var name = event.key;
var code = event.code;
if (name === 'Control') {
location.replace(classroom.google.com)
}
if (event.ctrlKey) {
alert(`Combination of ctrlKey + ${name} \n Key code Value: ${code}`);
} else {
alert(`Key pressed ${name} \n Key code Value: ${code}`);
}
}, false);
// Add event listener on keyup
document.addEventListener('keyup', (event) => {
var name = event.key;
if (name === 'Control') {
location.replace(classroom.google.com)
}
}, false);
I'm facing an issue where pressing the control key does not trigger any action. However, when I change it to display an alert message, it works as expected. Should I use the window.location function instead?