The code below show you how to activate the Caps Lock button programmatically. Setting the locking state to Boolean.TRUE
will turn the Caps Lock on.
package org.kodejava.awt;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
public class TurnCapsLockOn {
public static void main(String[] args) throws Exception {
// Gets the default toolkit.
Toolkit toolkit = Toolkit.getDefaultToolkit();
// Update the locking state for caps lock button to true
// will turn the caps lock on.
toolkit.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, Boolean.TRUE);
}
}
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024