473,720 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

capturing Ctrl+S in IE browser

I want to be able to capture the user pressing Ctrl+S. I know that
the IE browser has a key binding for Ctrl+S but is there any way that
I can be notified of this key press anyway. I have found tons of
examples of capturing keys in IE but *none* of them work for capturing
Ctrl+S, Ctrl+F, Ctrl+P,etc or any key combination that has a binding
in IE. Does anyone know how to do this?
Jul 23 '05 #1
3 4969


Greg wrote:
I want to be able to capture the user pressing Ctrl+S. I know that
the IE browser has a key binding for Ctrl+S but is there any way that
I can be notified of this key press anyway. I have found tons of
examples of capturing keys in IE but *none* of them work for capturing
Ctrl+S, Ctrl+F, Ctrl+P,etc or any key combination that has a binding
in IE. Does anyone know how to do this?


The following shows that you get event handlers fired for such combinations:

document.onkeyd own = document.onkeyp ress = function (evt) {
if (!evt && window.event) {
evt = window.event;
}
var keyCode = evt.keyCode ? evt.keyCode :
evt.charCode ? evt.charCode : evt.which;
if (keyCode) {
if (evt.ctrlKey) {
var p = document.create Element('p');
p.appendChild(d ocument.createT extNode(evt.typ e + ': ' +
keyCode + ' (' + String.fromChar Code(keyCode) + ')'));
document.body.a ppendChild(p);
}
}
return true;
}

It doesn't look however as if you could cancel the default action
associated with Ctrl-P for instance.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Thanks, that worked great.

Martin Honnen <ma*******@yaho o.de> wrote in message news:<41******* *@olaf.komtel.n et>...
Greg wrote:
I want to be able to capture the user pressing Ctrl+S. I know that
the IE browser has a key binding for Ctrl+S but is there any way that
I can be notified of this key press anyway. I have found tons of
examples of capturing keys in IE but *none* of them work for capturing
Ctrl+S, Ctrl+F, Ctrl+P,etc or any key combination that has a binding
in IE. Does anyone know how to do this?


The following shows that you get event handlers fired for such combinations:

document.onkeyd own = document.onkeyp ress = function (evt) {
if (!evt && window.event) {
evt = window.event;
}
var keyCode = evt.keyCode ? evt.keyCode :
evt.charCode ? evt.charCode : evt.which;
if (keyCode) {
if (evt.ctrlKey) {
var p = document.create Element('p');
p.appendChild(d ocument.createT extNode(evt.typ e + ': ' +
keyCode + ' (' + String.fromChar Code(keyCode) + ')'));
document.body.a ppendChild(p);
}
}
return true;
}

It doesn't look however as if you could cancel the default action
associated with Ctrl-P for instance.

Jul 23 '05 #3
rh
Martin Honnen wrote:
Greg wrote:
I want to be able to capture the user pressing Ctrl+S. I know that
the IE browser has a key binding for Ctrl+S but is there any way that
I can be notified of this key press anyway. I have found tons of
examples of capturing keys in IE but *none* of them work for capturing
Ctrl+S, Ctrl+F, Ctrl+P,etc or any key combination that has a binding
in IE. Does anyone know how to do this?
The following shows that you get event handlers fired for such combinations:

<..> It doesn't look however as if you could cancel the default action
associated with Ctrl-P for instance.


With a bit of touch-up to your code, it may:

document.onkeyd own = document.onkeyp ress = function (evt) {
evt = evt || window.event;
var keyCode = evt.keyCode || evt.which || 0;
if (keyCode && evt.ctrlKey) {
try { evt.keyCode = 0;} catch(e) {}
var p = document.create Element('p');
var str = evt.type + ': ' +
keyCode + ' (' + String.fromChar Code(keyCode) + ')';
p.appendChild(d ocument.createT extNode(str));
document.body.a ppendChild(p);
return false;
}
return true;
}

The requirement to nullify the keyCode, as I recall, is a
long-standing IE peculiarity (the OP could remove the try/catch for
his stated requirement).

Your code, by the way, provides a fine demonstration of the
differences in the browsers key event handling.

../rh
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2458
by: Bilal | last post by:
Hi, Is there any way to capture the action Ctrl+N (whether it in a hidden button or keyword - doesn't matter) in html, javascript or php? I appreciate any suggestions. Thank you and kind regards Bils
13
9452
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to intercept the key so that I can do stuff on the server side to make the new window behave correctly? (We have a JSP-based webapp which stores state in the session. Now if two windows access (and modify!) the same session, then madness will result....
6
27908
by: Matt | last post by:
By using javascript, is it possible to disable the REFRESH functionality (F5 or refresh icon) in a browser? Please advise. Thanks!!
14
2543
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the internet, they have to login. I want to be able to capture that login versus their Windows login because I need to know who they are from any computer rather than only their computer. Any ideas? Thanks
16
9448
by: Alex Clark | last post by:
Hi All, I'm sure this must have been asked a million times due to it's usefulness, but are there any sensible solutions for disabling right click (and other services such as Ctrl+P, Browser hotkeys etc) on a Web-Browser control in VB.NET? Despite Googling for ideas on and off for a week now, I only found one solution and this was to implement IMessageFilter on the form and then trap all the incoming messages. Unfortunately, this...
6
2265
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely PC, but has a significant number of Macs running OS X, too. Googling around quickly turns up IM Grabber for the PC, which would seem to be just what they need. But there is no equivalent to be found for OS X. So if anyone knows of any such...
11
12115
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta http-equiv="Expires" content="0"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache"> This tags are part of the <headelement. Sample code that I have seen shows how to add metatags of the form:
1
2477
by: mark4asp | last post by:
<!-- // How to detect the rendering mode which the browser is currently in (works for IE6). // Ctrl+Shift+s displays indicates whether the browser is in quirks or standards mode. // Detect keypress var captureKeys = function(ev) { ev = ev || window.event; // gets the event in ie or ns kCode = ev.keyCode || ev.which; // gets the keycode in ie or ns
0
8833
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9126
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4482
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4748
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3186
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2125
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.