diff --git a/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt b/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt index f9b01ddcd6..3725f94d68 100644 --- a/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt +++ b/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt @@ -247,16 +247,15 @@ open class TrimeInputMethodService : LifecycleInputMethodService() { if (keyCode in KeyEvent.KEYCODE_NUMPAD_0..KeyEvent.KEYCODE_NUMPAD_EQUALS) { // ignore KP_X keys, which is handled in `CommonKeyboardActionListener`. // Requires this empty body becoz Kotlin request it - } else { - if (it.modifiers.shift) { - sendDownKeyEvent(eventTime, KeyEvent.KEYCODE_SHIFT_LEFT) - } + return + } + + it.modifiers.shift.apply { + if (this) sendDownKeyEvent(eventTime, KeyEvent.KEYCODE_SHIFT_LEFT) sendDownKeyEvent(eventTime, keyCode, it.modifiers.metaState) - if (it.modifiers.shift) { - sendUpKeyEvent(eventTime, KeyEvent.KEYCODE_SHIFT_LEFT) - } + if (this) sendUpKeyEvent(eventTime, KeyEvent.KEYCODE_SHIFT_LEFT) } } } else {