0

Can you just help me to provide javascript code which simulates CTRL+W event. Basically CTRL+w is used to close current browser tab. Here i want to perform similar operation through Javascript code.

Thanks in Advance.

Shiv
  • 17
  • 4
  • 1
    possible duplicate of [How to close current tab in a browser window?](http://stackoverflow.com/questions/2076299/how-to-close-current-tab-in-a-browser-window) – Niki van Stein Sep 25 '15 at 12:04

1 Answers1

-2

Try this

$(window).keypress(function(event) {
    if (event.which == 119 && event.ctrlKey){   
    event.preventDefault();
    alert("Ctrl-W pressed");
  }
});
Bhavin Shah
  • 92
  • 10