oeyvind toft said:
How do I capture the ctrl keypress?
You probably want the ctrl keydown, not keypress.
Make any keydown event handler, even
document.onkeydown = function(event){
event = event || window.event; //IE suckes
if ( event.keyCode == 17 ) {
// ctrl pressed
}
}
Is it possible for js to intercept the ctrl-n combination and prevent
the creation of a new IE window??
That depends on the browser, where the focus is, and the phase of the
moon. That is, not always. (Well, you do say IE window, so I assume
you are mostly interested in IE).
This might work in some browsers, including IE6.
document.onkeydown = function(e) {
e=e||window.event;
if (e.keyCode == 78) {
return false;
}
}
The more relevant question is: Why would you think you needed
to do this? Because I am pretty certain that you don't. After all,
you can still open new windows in many other ways.
(Have 3 huge books on js and none of them mention this subject)
Good books, then. They shouldn't tell you how to interfere with the
users' keyboard shortcuts. They are there for a reason, you know.
Sometimes I wish I had a blacklist, just like my bookmarks. If I
blacklist a page, my browser will never send me back to it without
a warning. Then I could blacklist pages that interfered with my
keyboard.
/L