0

How to check that key pressed is CapsLk.

    if(e2.getKeyChar() == ?)
{

text_area.setText("CapsLk is pressed")

}
Snowrain
  • 3
  • 5
  • [are you looking for something like InputEvent#isShiftDown?](https://docs.oracle.com/javase/7/docs/api/java/awt/event/InputEvent.html#isShiftDown()) or check [this SO Question](http://stackoverflow.com/questions/7435221/how-can-i-get-the-caps-lock-state-and-set-it-to-on-if-it-isnt-already) – SomeJavaGuy Aug 31 '16 at 09:08
  • The answer by px06 is the required answer here. Thank you. – Snowrain Aug 31 '16 at 10:10

1 Answers1

2
if(e2.getKeyCode() == KeyEvent.VK_CAPS_LOCK){
    text_area.setText("CapsLk is pressed");
}
px06
  • 2,256
  • 1
  • 27
  • 47