Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Determining caps lock state

Reply
Thread Tools

Determining caps lock state

 
 
Robert
Guest
Posts: n/a
 
      10-27-2005
Hi!

I was wondering if the was any way to determine the state of the caps
lock key, on or off.
Of course I can capture the key events and see whether the caps lock is
pressed, but that does not help.

I have seen some example that looks at the characters entered in an
input field to determine if the caps lock is on, but I was wondering if
something is possible that is a bit more immediate to report the caps
lock state.

Robert.
 
Reply With Quote
 
 
 
 
rf
Guest
Posts: n/a
 
      10-27-2005
Robert wrote:

> Hi!
>
> I was wondering if the was any way to determine the state of the caps
> lock key, on or off.
> Of course I can capture the key events and see whether the caps lock is
> pressed, but that does not help.
>
> I have seen some example that looks at the characters entered in an
> input field to determine if the caps lock is on, but I was wondering if
> something is possible that is a bit more immediate to report the caps
> lock state.


Why?

--
Cheers
Richard.
 
Reply With Quote
 
 
 
 
Robert
Guest
Posts: n/a
 
      10-27-2005
rf wrote:
> Robert wrote:
>
>
>>Hi!
>>
>>I was wondering if the was any way to determine the state of the caps
>>lock key, on or off.

>
> Why?


It is to alert that the caps lock is enabled on a form where a user can
change his password. I want to make a block visible when the caps lock
is enabled and hide it again when it is off.
I prefer to do it as similar as we do in a swing client.
 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      10-27-2005
Robert wrote:

> rf wrote:
>> Robert wrote:
>>
>>>Hi!
>>>
>>>I was wondering if the was any way to determine the state of the caps
>>>lock key, on or off.

>>
>> Why?

>
> It is to alert that the caps lock is enabled


I have a little light on my keyboard that indicates my caps lock status.

> on a form where a user can
> change his password.


Password fields should be, well, type="password" fields.

> I want to make a block visible when the caps lock
> is enabled and hide it again when it is off.


You are trying to change the behaviour of my browser. Don't. How do you
know I even *have* a caps lock button?

> I prefer to do it as similar as we do in a swing client.


What is a "swing client"?

--
Cheers
Richard.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      10-27-2005
Robert wrote on 27 okt 2005 in comp.lang.javascript:

> rf wrote:
>> Robert wrote:
>>>I was wondering if the was any way to determine the state of the caps
>>>lock key, on or off.

>>
>> Why?

>
> It is to alert that the caps lock is enabled on a form where a user can
> change his password. I want to make a block visible when the caps lock
> is enabled and hide it again when it is off.
> I prefer to do it as similar as we do in a swing client.


Better make the serverside password parsing caseinsensitive,

jscript-ASP:

password = request.form('password').toLowerCase();

or even better [securitywize] "case reversed" serverside,
and allow testing for both password and password2:

jscript-ASP:

password = request.form('password');
password2 = '';
for (i=0;i<password.length;i++){
l = password.charAt(i);
password2 +=
(l==l.toLowerCase())
?l.toUpperCase():l.toLowerCase();
};

[can this be done by regex, I wonder?]

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
Julian Turner
Guest
Posts: n/a
 
      10-27-2005

Robert wrote:

> Hi!
>
> I was wondering if the was any way to determine the state of the caps
> lock key, on or off.
> Of course I can capture the key events and see whether the caps lock is
> pressed, but that does not help.
>
> I have seen some example that looks at the characters entered in an
> input field to determine if the caps lock is on, but I was wondering if
> something is possible that is a bit more immediate to report the caps
> lock state.
>
> Robert.


I don't think you can do it within Javascript alone. Even Visual Basic
has to use an external user32.dll to get the caps lock state.

Here is a site with some kind of suggestion:-

http://www.howtocreate.co.uk/jslibs/...apsDetect.html

Can't vouch for it though.

Julian

 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      10-28-2005
rf wrote:
> Robert wrote:
>
>>>>I was wondering if the was any way to determine the state of the caps
>>>>lock key, on or off.
>>>
>>>Why?

>>
>>It is to alert that the caps lock is enabled

>
>
> I have a little light on my keyboard that indicates my caps lock status.


lol
Well it is neither for me or you. You should know how many regular users
have had problems with caps-lock and passwords.

>>on a form where a user can
>>change his password.

>
>
> Password fields should be, well, type="password" fields.


Uhmmm... yes of course. If they were type="text" then they could see
their uppercase characters and I would not ask for a caps-lock indication.

>>I want to make a block visible when the caps lock
>>is enabled and hide it again when it is off.

>
>
> You are trying to change the behaviour of my browser. Don't.


I am not changing the behaviour of your browser.
Does the caps-lock indication in a 'normal' windows application change
your operating system?

> How do you
> know I even *have* a caps lock button?


Well if you don't have it then you will never see the indicator.

>>I prefer to do it as similar as we do in a swing client.

>
>
> What is a "swing client"?


Sorry. I meant a Java application that uses Swing components.
 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      10-28-2005
Evertjan. wrote:
> Robert wrote on 27 okt 2005 in comp.lang.javascript:
>
>
>>rf wrote:
>>
>>>Robert wrote:
>>>
>>>>I was wondering if the was any way to determine the state of the caps
>>>>lock key, on or off.
>>>

> Better make the serverside password parsing caseinsensitive,


I would do that if I were responsible for the serverside.
Just busy making a webclient that resembles the Java swing client as
best what is possible.

> jscript-ASP:


I use Apache Tapestry
 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      10-28-2005
Julian Turner wrote:
> Robert wrote:
>
>
>>Hi!
>>
>>I was wondering if the was any way to determine the state of the caps
>>lock key, on or off.

>
> I don't think you can do it within Javascript alone. Even Visual Basic
> has to use an external user32.dll to get the caps lock state.
>
> Here is a site with some kind of suggestion:-
>
> http://www.howtocreate.co.uk/jslibs/...apsDetect.html


I found that already. The 'problem' with this is that the indicator
would only change when actually inside the input field and pressing a
character. Nothing would change by just pressing the caps-lock.

Anyway I have an idea now how it might be possible. If I succeed I will
post it on Monday.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      10-28-2005
Robert wrote on 28 okt 2005 in comp.lang.javascript:

>> jscript-ASP:

>
> I use Apache Tapestry


The latter is off topic.


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard CAPS LOCK only turns off with the shift key... BillyBob@nospam.com Computer Support 20 10-01-2013 08:44 PM
Sometimes Caps Lock comes on and stays on for no apparent reason GrandpaChuck Computer Support 18 02-15-2012 09:32 AM
Caps Lock State on Windows N3wCr4Zy Python 2 12-12-2009 04:47 AM
caps lock coming on spontaneously GrandpaChuck Computer Support 11 01-09-2007 08:25 PM
"Caps Lock" Key Problem Julie P. Computer Support 11 07-08-2004 04:16 AM



Advertisments