Thanks in advance.
I don't believe you can do that. If you just want to close the tab/window you can use window.close().
You can test which keys are pressed, but you can't fake a key press - meaning, you can't control the user's keyboard, otherwise, you would be able to close out programs and windows when the user doesn't want that.
but you might be able to do something like this: http://www.w3schools.com/jsref/met_win_close.asp