From: Krist on
Hi All,

In our web application we want to disable user from pressing CTRL key.
and we want to implement this for IE, Firefox and if possible other
browser.

I have tried this code, doesn't work :

<script type="text/javascript">
document.onkeyup = KeyCheck;
function KeyCheck()
{
var KeyID = (window.event) ? event.keyCode : e.keyCode;
if ( KeyID == 17) {
alert("Test Alert System");
}
}
</script>

Pls help me to fix the code...

Thank you very much,
Krist

From: The Natural Philosopher on
Krist wrote:
> Hi All,
>
> In our web application we want to disable user from pressing CTRL key.
> and we want to implement this for IE, Firefox and if possible other
> browser.
>
> I have tried this code, doesn't work :
>
> <script type="text/javascript">
> document.onkeyup = KeyCheck;
> function KeyCheck()
> {
> var KeyID = (window.event) ? event.keyCode : e.keyCode;
> if ( KeyID == 17) {
> alert("Test Alert System");
> }
> }
> </script>
>
> Pls help me to fix the code...
>
> Thank you very much,
> Krist
>
I think you will find that since javascript only works INSIDE a browser,
it can only deal with key presses that the operating system passes
through to the browser.

CTTRL is not necessarily one of those, since at least on windows, you
NEED Ctrl-Alt-del to maintain normal operation of the computer.;-0


From: Amrit Ranjan on
On Dec 11, 3:45 pm, The Natural Philosopher <t...(a)invalid.invalid>
wrote:
> Krist wrote:
> > Hi All,
>
> > In our web application we want to disable user from pressing CTRL key.
> > and we want to implement this for IE, Firefox and if possible other
> > browser.
>
> > I have tried this code, doesn't work :
>
> > <script type="text/javascript">
> > document.onkeyup = KeyCheck;
> > function KeyCheck()
> > {
> >    var KeyID = (window.event) ? event.keyCode : e.keyCode;
> >    if ( KeyID  == 17) {
> >         alert("Test Alert System");
> >    }
> > }
> > </script>
>
> > Pls help me to fix the code...
>
> > Thank you very much,
> > Krist
>
> I think you will find that since javascript only works INSIDE a browser,
> it can only deal with key presses that the operating system passes
> through to the browser.
>
> CTTRL is not necessarily one of those, since at least on windows, you
> NEED Ctrl-Alt-del to maintain normal operation of the computer.;-0

Hi your code will work fine with IE, Safari, Chrome, Opera except
Mozilla. It is because the function definition KeyCheck() should look
like KeyCheck(e). Actually Mozilla passes event object as an
arguments. I had added "e" with your code. Do you want to cancel this
event?

function KeyCheck(e)
{
var KeyID = (window.event) ? event.keyCode : e.keyCode; //e is not
global variable is is the argument
if ( KeyID == 17) {
alert("Test Alert System");
}
}
From: Krist on
On 11 Des, 19:01, Amrit Ranjan <amri...(a)gmail.com> wrote:
> On Dec 11, 3:45 pm, The Natural Philosopher <t...(a)invalid.invalid>
> wrote:
>
>
>
>
>
> > Krist wrote:
> > > Hi All,
>
> > > In our web application we want to disable user from pressing CTRL key..
> > > and we want to implement this for IE, Firefox and if possible other
> > > browser.
>
> > > I have tried this code, doesn't work :
>
> > > <script type="text/javascript">
> > > document.onkeyup = KeyCheck;
> > > function KeyCheck()
> > > {
> > >    var KeyID = (window.event) ? event.keyCode : e.keyCode;
> > >    if ( KeyID  == 17) {
> > >         alert("Test Alert System");
> > >    }
> > > }
> > > </script>
>
> > > Pls help me to fix the code...
>
> > > Thank you very much,
> > > Krist
>
> > I think you will find that since javascript only works INSIDE a browser,
> > it can only deal with key presses that the operating system passes
> > through to the browser.
>
> > CTTRL is not necessarily one of those, since at least on windows, you
> > NEED Ctrl-Alt-del to maintain normal operation of the computer.;-0
>
> Hi your code will work fine with IE, Safari, Chrome, Opera except
> Mozilla. It is because the function definition KeyCheck() should look
> like KeyCheck(e). Actually Mozilla passes event object as an
> arguments. I had added "e" with your code. Do you want to cancel this
> event?
>
> function KeyCheck(e)
> {
>    var KeyID = (window.event) ? event.keyCode : e.keyCode; //e is not
> global variable is is the argument
>    if ( KeyID  == 17) {
>         alert("Test Alert System");
>    }
>
>
>
> }- Sembunyikan teks kutipan -
>
> - Perlihatkan teks kutipan -- Sembunyikan teks kutipan -
>
> - Perlihatkan teks kutipan -

Hi Sir,
Thank you for your reply. further question..

To tell the page to run KeyCheck, I use this code :

document.onkeyup = KeyCheck;

How to make it conditionally call KeyCheck or KeyCheck(event) based on
what browser it is running ?

Thank you,
Krist







From: Swifty on
Krist wrote:
> Hi All,
>
> In our web application we want to disable user from pressing CTRL key.
> and we want to implement this for IE, Firefox and if possible other
> browser.

If you manage to disable me from pressing the Ctrl key, for goodness
sake don't let my wife find out, otherwise she'd prevent me from
pressing all the other keys. :-)

There are some who would say that this is a good thing.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk