开发者

How to check if Scroll Lock is on or off?

开发者 https://www.devze.com 2023-01-22 02:52 出处:网络
How does one check to see if Scroll Lock is enabled on开发者_如何学编程 a system or not in Java?import java.awt.Toolkit;

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

精彩评论

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