您如何在没有事件听众的情况下检查Capslock最初是否亮着?

发布于 2025-02-10 08:50:23 字数 474 浏览 1 评论 0原文

我一直在查看的答案溢出问题,几乎只有大量答案显示出不同的方式来检查Capslock是否在开启,并有一些活动的侦听器。

在那些解决方案中,我发现我认为这是其中最好的一种,但是所有这些都有一个问题。它们都取决于某种输入(onkeyup单击使用侦听器),我想(如果可能的话)检查该页面已加载页面以检查页面如果Capslock当前打开,然后使用我选择的解决方案,以检查Capslock状态在输入过程中是否更改。

这可能吗?
有什么方法可以使用event.getModifierstate而无需event

I have been looking through the answers to this Stack Overflow question, and it is pretty much just a ton of answers showing different ways to check if CapsLock is on, with some event listener.

In those many solutions, I found one that I think is the best of them all, but there is one problem with all of them. They all depend on some sort of input (onkeyup or click listeners are used), I would like to (if possible) do a check the instant the page is loaded to check if CapsLock is currently on, and then use the solution I chose, to check if the CapsLock state changes during input.

Is this possible?
Is there some way that we can just use the event.getModifierState without having an event?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文