What I want to do is to close a webpage using the shortcut control + W.
Can I write a piece of code that will simulate the shortcut (control+W).
What I want to do is to close a webpage using the shortcut control + W.
Can I write a piece of code that will simulate the shortcut (control+W).
I think this is what you are looking for:
document.addEventListener('keydown', function(event) {
if(event.key == "Control" && event.key == "w") {
close();
}
});