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 create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023