473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Determining caps lock state

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.
Oct 27 '05 #1
18 4883
rf
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.
Oct 27 '05 #2
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.
Oct 27 '05 #3
rf
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.
Oct 27 '05 #4
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)

Oct 27 '05 #5

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

Oct 27 '05 #6
In article <j0*****************************@40tude.net>,
rf <rf@invalid.com> wrote:
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?


No he's not. He's trying to provide additional visual feedback. If
that's an example of changing the behavior of your browser, then so is
alert("password is case sensitive");

That said, it does strike me as a quixotic quest.
Oct 27 '05 #7
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.
Oct 28 '05 #8
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 :)
Oct 28 '05 #9
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.
Oct 28 '05 #10
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)

Oct 28 '05 #11
Robert wrote on 28 okt 2005 in comp.lang.javascript:
I would do that if I were responsible for the serverside.


<input type='password'
onblur='this.value=this.value.toLowerCase();'>

will do clientside, but you have to convince all users that haven't
all lowecase pwds to change them.

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

Oct 28 '05 #12
VK
> Determining caps lock state

I may be missing some extra issue here, but where is the problem?
CapsLock Unicode value is 20
So just monitor it via keyDown or keyUp (not keyPress!)

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function init() {
document.onkeydown = test;
}

function test(e){
if (e) {
alert(e.which);
}
else {
alert(event.keyCode);
}
}
window.onload = init;
</script>
</head>

<body bgcolor="#FFFFFF">

</body>
</html>

Oct 28 '05 #13
VK said the following on 10/28/2005 8:48 AM:
Determining caps lock state

I may be missing some extra issue here, but where is the problem?
CapsLock Unicode value is 20
So just monitor it via keyDown or keyUp (not keyPress!)

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function init() {
document.onkeydown = test;
}

function test(e){
if (e) {
alert(e.which);
}
else {
alert(event.keyCode);
}
}
window.onload = init;
</script>
</head>

<body bgcolor="#FFFFFF">

</body>
</html>


Because that does not tell you the state it is in. Only if the key was
pressed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 28 '05 #14
Evertjan. wrote:
Robert wrote on 28 okt 2005 in comp.lang.javascript:
I would do that if I were responsible for the serverside.

<input type='password'
onblur='this.value=this.value.toLowerCase();'>

will do clientside, but you have to convince all users that haven't
all lowecase pwds to change them.


Thanks, but it really is not an option.
Oct 28 '05 #15
Evertjan. wrote:
Robert wrote on 28 okt 2005 in comp.lang.javascript:

jscript-ASP:


I use Apache Tapestry :)

The latter is off topic.


I know... just for your information.
Anyway, neither Tapestry or javascript would have been the correct place
to implement lowercase password. Because that would not help those
changing passwords with their Java Swing application.
But all of this is getting off-topic.
Oct 28 '05 #16
> "Robert" <ro****@noreply.x> wrote:
news:43***********************@news.xs4all.nl....

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.


http://www.howtocreate.co.uk/jslibs/otherdemo.html#cld

--
BootNic Friday, October 28, 2005 9:01 PM

I try to take one day at a time, but sometimes several days attack me at once.
*Jennifer Unlimited*

Oct 29 '05 #17
BootNic wrote:
"Robert" <ro****@noreply.x> wrote:
news:43***********************@news.xs4all.nl... .

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.

http://www.howtocreate.co.uk/jslibs/otherdemo.html#cld


Thanks, but like I said I know about this already.
I was looking for something better.
Oct 29 '05 #18
VK

Robert wrote:
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.


There must be somewhere a pre-historic keysta32.ocx control for Windows
95 (CLASSID="clsid:B9D22270-0C24-101B-AEBD-04021C009402"). It gave you
Num Lock, Caps Lock and Scroll Lock states. You may try to find it and
see if it still works on current Windows dll's.

JavaScript / JScript by themselve have nothing to propose on this
matter within the chosen approach.

Oct 30 '05 #19

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

Similar topics

4
by: Peter D | last post by:
I have a second hand bar code reader (keyboard wedge) en i can read the bar codes but after every scan he turns my caps lock on. (GRRRRRR). I search a code to turn my caps lock off or can anyone...
3
by: Mike L | last post by:
How do I turn Caps Lock on, when my form opens?
5
by: Steven | last post by:
Can anyone tell me how to toggle the "Caps Lock" key? Thanks in advance
2
by: GSX | last post by:
Would somebody be able to point me in the direction of figuring out how to determine if Caps Lock is on, Num Lock is on, INS or OVR, etc.? I'm looking to display their status in a statusbar, but...
0
by: fNew VBer | last post by:
Hi. I'm new to Visual Basic .NET, so you'll have to bear with me . . . I want to create an app that turns off CAPS LOCK when the SHIFT key is pressed. I got the code to turn off CAPS LOCK to...
1
by: yxq | last post by:
Hello, I have a main form, there other some controls(i.e. textbox) in the form. I want to detect whether Caps Lock key is pressed in form-key event. Private Sub Form1_KeyUp(ByVal sender As...
1
by: charlies224 | last post by:
Hi, I am writting a software that requires me to make sure the Num Lock is always on and Caps Lock is always off. First, I know how to detect if Num Lock or Caps Lock is on or off (if...
4
by: zacks | last post by:
I'm not sure when it came into being, since this it the first time I have worked very much with a password control in .NET, but if a textbox that has a non-empty value for PasswordChar or the...
1
by: cmrhema | last post by:
Hi, Two questions 1. In windows application if we put on the below code, it will identify whether caps lock is on or not if (TextBox.IsKeyLocked(Keys.CapsLock)) { ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.