Javascript to detect number lock , on or off

Status
Not open for further replies.

ghemant

Broken In
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
 

sakumar79

Technomancer
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

Broken In
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

Technomancer
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 :)
 

puja399

In the zone
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

Cyborg Agent
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

In the zone
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.
 
Status
Not open for further replies.
Top Bottom