Check Scroll Lock, Num Lock & Caps Lock in JavaScr

2020-02-12 09:01发布

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.

2条回答
家丑人穷心不美
2楼-- · 2020-02-12 09:21

IN 2019, this is now possible:

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

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

查看更多
Fickle 薄情
3楼-- · 2020-02-12 09:32

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

查看更多
登录 后发表回答