Ruang penulis
← Kembali ke jurnal
AWT

How do I read the status of Caps Lock key?

This example show you how to detect if the Caps Lock key is in active mode. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class CapsLockState { public static void main(String[] args) { // Get the locking state of the Caps Lock button. This method // return boolean true value if it is "on". boolean isOn […]

DWayan · 23 Des 2009 · 1 menit baca

Artikel oleh Wayan · Sumber: Kode Java ↗

Terjemahan artikel ini belum tersedia. Isi asli ditampilkan.

This example show you how to detect if the Caps Lock key is in active mode.

package org.kodejava.awt;

import java.awt.Toolkit;
import java.awt.event.KeyEvent;

public class CapsLockState {
    public static void main(String[] args) {
        // Get the locking state of the Caps Lock button. This method
        // return boolean true value if it is "on".
        boolean isOn = Toolkit.getDefaultToolkit().getLockingKeyState(
                KeyEvent.VK_CAPS_LOCK);

        System.out.println("CapsLock button is " + (isOn ? "on" : "off"));
    }
}
← Jelajahi catatan lainnya