Connect with Expertise | Find Experts, Get Answers, Share Insights

Regarding php!

 
Join Date: Jan 2010
Posts: 1
#1: Jan 17 '10
Hi,

I wana ask how do I implement the code for Caps lock in php...forexample: if I wana login and capslock is On, whenever I type my login the msg or alert msg should prompt that capslock is On.so when I press caps lock again to make it caps lock off, then program should allow me to enter login name..

Thx!

dgreenhouse's Avatar
E
C
 
Join Date: May 2008
Location: San Francisco
Posts: 154
#2: Jan 18 '10

re: Regarding php!


If the visitor can't see that they have the 'caps lock' on then they're probably not the kind of visitor you want! :-)

Seriously, as far as I know you can't detect the "caps lock" state in php. I'm not even sure if you can do "caps lock" detection using php's in a command line based app - I've never bothered to try and discover. On the other hand, you can do it in JavaScript.

Here's a link I found showing it implemented in javascript:
http://www.codeproject.com/KB/script...Caps_Lock.aspx
Markus's Avatar
E
C
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 5,530
#3: Jan 18 '10

re: Regarding php!


Hm, I believe that JS only checks that the shift key is pressed.

Anyway, with PHP being use typically as a server-side processor, for you to be aware of whether the caps-lock key is pressed, well, you'd have to pass that information to the server which defeats the point of PHP detecting it (not to mention you'd need to refresh the page / make an ajax call).

However, if you were doing this as a desktop application with PHP as the driving-force behind it, you could write an extension to find the caps-lock-key's state. I may have a look into doing that now.

Mark.
Reply