开发者

How to check if Scroll Lock is on or off?

How does one check to see if Scroll Lock is enabled on开发者_如何学编程 a system or not in Java?


import java.awt.Toolkit;

import java.awt.event.KeyEvent;

Toolkit toolkit = Toolkit.getDefaultToolkit();

toolkit.getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);

Source: http://www.kodejava.org/examples/574.html


use getLockingKeyState() method from toolkit

Toolkit toolkit=Toolkit.getDefaultToolkit();
toolkit.getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);

You can also set them ON / OFF by

toolkit.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK,true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜