简体   繁体   中英

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.

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 =/

IN 2019, this is now possible:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM