This example show you how to detect if the Scroll Lock key is in active mode. If you run the program you will get an output telling you that the Scroll Lock button is active or not active.
package org.kodejava.awt;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
public class ScrollLockState {
public static void main(String[] args) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
// Get the locking state of the Scroll Lock button. This method
// return boolean true value if it is "on".
boolean isOn = toolkit.getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
System.out.println("ScrollLock button is " + (isOn ? "on" : "off"));
}
}
Latest posts by Wayan (see all)
- How do I build simple search page using ZK and Spring Boot? - March 8, 2023
- How do I calculate days between two dates excluding weekends and holidays? - January 12, 2023
- How do I discover the quarter of a given date? - January 11, 2023