How to Detect CapsLock key using Java in NetBeansIDE

Опубликовано: 16 Апрель 2026
на канале: raksrahul
1,692
15

How to Detect CapsLock key using Java in NetBeansIDE.

Note:
packages and classes used:

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

1. Open NetBeansIDE.

2. Make a new project say DemoCaps.

3. Make a new JFrame Form in it say CapsLockDetect and design it.

4. RC on Form and Goto Properties~Events~KeyPressed~Select formKeyPressed.

5. Write the following code in the method and Fix all imports:

if(Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK))
{
jLabel.setText("ON");
}
else
{
jLabel.setText("OFF");
}

6. Run the Project.

7. Finish.

Thank You :)

#java #NetBeansIDE #programming #coding #developer #tips #tricks