How can I get the caps lock state in Android using a hardware keyboard? In pure Java it can be detected with
boolean isOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
But this does not work with Android...
Try This (didn't test it):
public class CustomEditText extends EditText{
public CustomEditText(Context context) {
super(context);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.isCapsLockOn()){
//Do what Ever
}
return super.onKeyDown(keyCode, event);
}
}
isCapsLockOn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With