# Javascript to detect number lock , on or off



## eureca_eureca (Dec 19, 2005)

Please help me find a code for javascript which can detect whether number lock button is on or off..


----------



## ghemant (Dec 20, 2005)

*Java Script*

Hi,
you can find it from www.planet-source-code.com



Regards


----------



## eureca_eureca (Dec 20, 2005)

ghemant i couldnt ind that script there ..


----------



## ghemant (Dec 21, 2005)

*NumLock on or Off*

Hi, 
please find the link for HOW TO CAPTURE A KEY STROKES USING JAVA SCRIPT , NOW I THINK YOU CAN DO THE TWEAK.

*www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2999&lngWId=2



Regards


----------



## eureca_eureca (Dec 21, 2005)

ghemant that code will capture key codes, bu how to get true or false for the num lock , ie if its on or of ?


----------



## sakumar79 (Dec 21, 2005)

Afaik, it is not possible to check status of numlock from javascript... The ability to detect keypress comes from usage of events, but this is a sytem status which I do not think is made available. 

BTW, why do you want to do it? Perhaps an alternative method might be available. Or perhaps you can use a different scripting tool that can check the status such as VBScripts though not sure if they have ability to do it...

Arun


----------



## ghemant (Dec 22, 2005)

*Num Lock Status*

Hi,
its their in vb to identify  / status , if num lock is on or not and its their in vb and java tooo , as if javascript is able to capture the keystrokes you have to do the tweak and its a possible thats what i feel.


Regards


----------



## tuxfan (Dec 22, 2005)

Status of Num Lock, Caps Lock, Scroll Lock, etc. is stored in memory at location number 0x417. Now C lets you use pointers and access that memory location and with the value stored there you can find out the state.

VB is a totally different thing altogether. Although, there are no pointers, there are built-in functions/controls to do this.

You can't use pointers with Javascript (thankfully!!). So unless there is a built in library function to do this, its not possible. In 15-20 minutes I couldn't find any such library function from the Javascript 1.4 Reference that I have.  So I doubt that its possible at least till Javascript 1.4

But don't lost heart, keep trying and let us all know if you find it


----------



## eureca_eureca (Dec 22, 2005)

i tried saearching for vbscript too , i couldnt find there too..
Thx ever one for the help ..


----------



## puja399 (Dec 23, 2005)

However, there is a workaround. U need to build a COM wrapper for a suitable API, viz, "GetAsyncKeyState" and use that object through ur vbs program. You have to distribute that COM object also with ur script file in case u need to run it somewhere else.


----------



## icecoolz (Dec 25, 2005)

well sounds like hellava lot of work just to find out if the Null lock is active or not. AFAIK there is no way to know in javascript if things such as Scroll lock, num lock and so on are active. And as for the C, java, VB which allows you to be able to detect these, remember javascript still works within the dimensions of your browser, where in the others they have access to the system and hence are not running in a "sandbox" environment.


----------



## puja399 (Dec 25, 2005)

Ya, u r right. U can't do it in javascript. It was my mistake that I misunderstood the problem and gave a solution for VBScript.


----------

