有什么方法可以打开/关闭 Num、Caps 和 Scroll Lock 灯吗?

发布于 2024-11-04 17:22:15 字数 72 浏览 4 评论 0原文

有什么方法可以打开/关闭 Num、Caps 和 Scroll Lock 灯吗?这只是为了好玩,我的想法是做一些像迪斯科这样的事情。

Is there any way to turn on/off Num, Caps and Scroll Lock lights? It's just for fun and my idea is to do something like disco.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

有木有妳兜一样 2024-11-11 17:22:15

尝试

Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, true);

将大写锁定设置为打开。

Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);

将大写锁定设置为“关闭”。

boolean isCapsLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);

获取当前状态。

使用 KeyEvent.VK_NUM_LOCK 进行数字锁定。

我已经在 Windows 上对此进行了测试。我不确定其他操作系统,但我认为它会起作用。

Try

Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, true);

to set Caps lock On.

Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);

to set Caps lock Off.

and

boolean isCapsLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);

to get current status.

use KeyEvent.VK_NUM_LOCK for num lock.

I have tested this on Windows. I'm not sure about other OSs but I would think it would work.

樱娆 2024-11-11 17:22:15

我认为您无法以直接的方式独立于其自身的激活来设置大写/滚动锁定的灯光。

您只能通过编写自己的键盘驱动程序来实现这种行为(或者最终浏览网页以查找可能已经开发出来的驱动程序来实现这种行为),但不建议这样做,并且远远超出了 java 的界限。

另外,这个问题与 如何在不实际打开大写锁定的情况下打开键盘的大写锁定灯?,即使在另一个问题中该行为是在 C# 中实现的。

然而,问题、不可能性以及解决方法都是一样的。

I think you cannot set Caps/Scroll lock's lights independently from their own activation, in a direct way.

You could only achieve such behaviour by programming a keyboard driver of your own (or eventually browsing the web for a driver that might already have been developed to achieve such a behavior), but that is not recommended, and goes way beyond the boundaries of java.

Also, this question is a similar duplicate of Way to turn on keyboard's caps-lock light without actually turning on caps-lock? , even though in this other question that behavior is intended in C#.

However, the issue, impossibility, and the way around it, are the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文