SupportWriter space ↗
← Back to the journal
AWT

How do I turn on the Caps Lock button?

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 […]

DWayan · 28 Dec 2009 · 1 min read

Article by Wayan · Source: Kode Java ↗

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);
    }
}
← Explore more notes