Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Scroll Lock, Num Lock & Caps Lock in JavaScript on Page Load

Is it possible to check the status of Scroll Lock, Num Lock and Caps Lock on page load of a web page? I've found ways to check after a keypress using JavaScript, but that's not what I'm asking.

like image 936
MacGyver Avatar asked Jan 30 '12 06:01

MacGyver


People also ask

How do I know if Scroll Lock is on?

You can tell if Scroll Lock is turned on, because Scroll Lock appears in the Excel status bar. If you suspect that Scroll Lock is turned on, but Scroll Lock does not appear in the Excel status bar, it may be because the status bar is customized to hide the Scroll Lock status.

Why can't I turn off Scroll Lock?

To turn off Scroll Lock, press the Scroll Lock key (often labeled as ScrLk) on your keyboard. If your keyboard doesn't have a Scroll Lock key, on your computer, click Start > Settings > Ease of Access > Keyboard, and then turn off the Use the On-Screen Keyboard slider button.


2 Answers

IN 2019, this is now possible:

var x = event.getModifierState("ScrollLock"); 

Source: https://www.w3schools.com/jsref/event_mouse_getmodifierstate.asp

like image 76
thebiss Avatar answered Sep 21 '22 04:09

thebiss


No, you can't get system state from javascript. You will need them to type something and then analyze the input. Probably not what you wanted to hear =/

like image 33
mrtsherman Avatar answered Sep 19 '22 04:09

mrtsherman