[Javascript] Capture Ctrl-keys in Input Text or forms objects.
Jean-Francois Larocque (LMC)
Jean-Francois.Larocque at ericsson.ca
Wed Jul 24 13:37:18 CDT 2002
Hi, I am developping a Secure web browser for an intranet.
basically we want to control the pages accessed.
I have control on the client side of Netscape 4.75
so we launch it in kioskmode (No menu, buttons, status or location bar)
I want to keep my users to use CTRL-O or CTRL-N because when the new window
appears,
the kioskmode is not preserved.
I wrote the following script to capture events related to rightt click and
CTRL-keys functions
but I enconter the following problem:
When the focus is in a form, the onKeyPress does not catch the CTRL key
combinaison attached to Netscape functions.
So a user could manage to open a new windows by pressing CTRL-New when the
focus is in a form.
In the form, it seems that the only event captured is onkeyup.
I capture the events at the highest level, ie in the windows object.
Should I capture it specifically in the form?
What woulb be the syntax?
<SCRIPT LANGUAGE="JavaScript1.2"><!--
function netscapeKeyPress(e) {
if (e.modifiers )//& Event.CONTROL_MASK )
alert('Ctrl keys is not allowed in this secure browser');
}
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 )){
alert("Right click is not allowed in this secure browser.");
return false;
}
if (navigator.appName == 'Netscape' && (e.which == 2)){
alert("Middle click is not allowed in this secure browser.");
return false;
}
return true;
}
window.captureEvents(Event.KEYPRESS);
window.captureEvents(Event.MOUSEDOWN);
window.onKeyPress = netscapeKeyPress;
window.onmousedown=right;
//--></SCRIPT>
</HEAD>
<BODY>
<BR><BR><BR>
<form NAME=output>
<p><input type="text" onKeyPress="netscapeKeyPress(event)"
size="20">
</form>
</BODY>
I searched the usegroup and it seems that the problem was encontered before
but
I could not extract an applicable solution to my problem.
Here are the links to the previous threads related to my problem:
http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&selm=3547027F.DEFB15DB%40w
ipsys.soft.net
http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&threadm=3614105F.B1856B9D%
40sector27.de&rnum=13&prev=/groups%3Fq%3Djavascript%2Bctrl%2Bevent%2Bcapture
%26start%3D10%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3D3614105F.B1856B9D%2540
sector27.de%26rnum%3D13
http://groups.google.ca/groups?q=javascript+ctrl+event+capture+form&hl=en&lr
=&ie=UTF-8&scoring=d&selm=38E90DCF.4BBC14E5%40knowspam.lucasfilm.com&rnum=9
Netscape 4.75
Jean-François Larocque
LMC/XB/A CDMA OSS Integration
Ericsson Research Canada
8300 Boulevard Decarie
Ville Mont-Royal (Quebec)
Canada H4P 2P5
Tel: 514-345-7900 x2208
mailto:lmcjfla at lmc.ericsson.se
More information about the Javascript
mailing list