Android onKeyDown captures the keycode value problem

The

android
function needs to capture the number pressed by the user is 1-9
but the value obtained by the 1-9 key is different due to the problem of switching the input method.
is there any way to ensure that the keycode will be converted to a fixed value regardless of the input method?
I don"t want to write a lot of case.

Mar.20,2022

get the corresponding letters and numbers according to keycode

private void checkLetterStatus(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT || keyCode == KeyEvent.KEYCODE_SHIFT_LEFT) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            //shift
            mCaps = true;
        } else {
            //shift
            mCaps = false;
        }
    }
}

//keycode
private void keyCodeToNum(int keycode) {
    if (keycode >= KeyEvent.KEYCODE_A && keycode <= KeyEvent.KEYCODE_Z) {
        if (mCaps) {
            stringBuilder.append(map.get(keycode).toUpperCase());
        } else {
            stringBuilder.append(map.get(keycode));
        }

    } else if ((keycode >= KeyEvent.KEYCODE_0 && keycode <= KeyEvent.KEYCODE_9)) {
        stringBuilder.append(keycode - KeyEvent.KEYCODE_0);
    } else {
        //
        Log.i("",keycode+"");
    }
}
Menu