如果按下按钮是CapsLk

时间:2016-08-31 09:06:17

标签: java keyevent

如何检查按下的键是CapsLk。

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

text_area.setText("CapsLk is pressed")

}

1 个答案:

答案 0 :(得分:2)

if(e2.getKeyCode() == KeyEvent.VK_CAPS_LOCK){
    text_area.setText("CapsLk is pressed");
}