Scott on Writing

Musings on technical writing...

Tuesday, May 13, 2008 #

Warning the User When Caps Lock is On

After my first batch of Security Tutorials were published on www.asp.net, a reader emailed me asking if it was possible to display some sort of warning if the user has Caps Lock on whilst entering their password into the Login control. While JavaScript cannot indicate if Caps Lock is on or not, you can ascertain whether it is once the user types an alphabetic key, as JavaScript can determine the key pressed and whether the Shift key was also pressed. In short, if the character is upper case and Shift is not depressed, or if the character is lowercase but Shift is depressed, then it follows that Caps Lock is on.

So it is possible to write a bit of JavaScript that fires when the user types a key into a TextBox and display some warning in response. This ASP.NET Forums post - Give Warning When Caps Lock On - discusses a JavaScript-based solution. The downside is that you have to paste in the necessary JavaScript into the page and add JavaScript to the TextBox control's onkeypressed client-side event. Wouldn't it be easier to be able to drag and drop a control onto the page, set a few properties and, presto, have a working Caps Lock warning?

My latest 4Guys article, Warning the User When Caps Lock is On, looks at building such a control. It is now part of my skmControls2 collection, which includes (currently) two other open-source server controls:

For more open-source, free tools, controls, and other funery, check out My Code Projects.

Enjoy!

posted @ 8:50 PM | Feedback (0)

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1987.0%
Monday 39914.0%
Tuesday 47916.8%
Wednesday 53018.6%
Thursday 54919.3%
Friday 51718.2%
Saturday 1766.2%
Total 2848100.0%

Hour1Total% of Total
12:00 AM 702.5%
1:00 AM 762.7%
2:00 AM 652.3%
3:00 AM 762.7%
4:00 AM 612.1%
5:00 AM 1144.0%
6:00 AM 1113.9%
7:00 AM 1635.7%
8:00 AM 1786.3%
9:00 AM 1535.4%
10:00 AM 1766.2%
11:00 AM 1846.5%
12:00 PM 1926.7%
1:00 PM 1796.3%
2:00 PM 1625.7%
3:00 PM 1344.7%
4:00 PM 1134.0%
5:00 PM 1003.5%
6:00 PM 933.3%
7:00 PM 1033.6%
8:00 PM 893.1%
9:00 PM 822.9%
10:00 PM 842.9%
11:00 PM 903.2%
Total 2848100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.14144
Monday 5.22360
Tuesday 4.33459
Wednesday 7.55649
Thursday 6.77636
Friday 5.31430
Saturday 5.15170
Total 5.732848

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.05111
9:00 AM 6.04284
10:00 AM 6.27257
11:00 AM 4.28184
12:00 PM 6.88344
1:00 PM 3.03121
2:00 PM 5.29222
3:00 PM 8.60301
4:00 PM 3.7694
5:00 PM 5.79162
6:00 PM 4.56114
7:00 PM 9.58182
8:00 PM 8.37159
9:00 PM 5.00115
10:00 PM 6.2794
11:00 PM 4.5732
Total 5.732848

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles