Calculator does not register numbers entered on hw keyboard (Clicks case for Razr)
Checklist
- [x] I can reproduce the bug with the latest version given here.
- [x] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
- [x] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
- [x] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
- [x] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
- [x] This issue contains only one bug.
- [x] I have read and understood the contribution guidelines.
Affected app version
1.1.0
Affected Android/Custom ROM version
Android 15
Affected device model
Motorola Razr 50 Ultra + Clicks case
How did you install the app?
F-Droid / IzzyOnDroid
Steps to reproduce the bug
- Open app.
- Try to enter number via Clicks keyboard.
- Nothing is entered - no matter if NumLock is active or not.
Expected behavior
Numbers should be entered correctly (On Google calculator, numbers can be entered without any problem.).
Actual behavior
Nothing happens after numbers on the hw keyboard are pressed.
Screenshots/Screen recordings
No response
Additional information
No response
8BitDo Retro 18 Mechanical Numpad doesn't work either, but does work in Samsung preinstalled calculator app
Likely root cause (dev hint)
Many apps only listen for KEYCODE_0 … KEYCODE_9 (top row) or rely solely on IME text events. Hardware numpads send KEYCODE_NUMPAD_0 … KEYCODE_NUMPAD_9. If these are not handled (or if a key listener consumes them), digits “vanish”.
On Android 13+ this can surface when:
The view consumes key events via OnKeyListener/dispatchKeyEvent without passing numpad codes to the Editable, or
The EditText uses input filters or inputType combinations that prevent raw key events from committing characters, or
A custom key handling path checks event.keyCode in KEYCODE_0..KEYCODE_9 but not KEYCODE_NUMPAD_*.
Minimal fix (one of these)
Option A — Let the IME/TextView do its job
Ensure the input is a plain EditText/TextInputEditText with a numeric inputType and no custom key listener consuming events:
<EditText android:id="@+id/numberInput" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number|numberDecimal|numberSigned" android:digits="0123456789.-" />
Remove any setOnKeyListener that returns true for unknown codes.
Option B — Handle numpad keycodes explicitly (if you must intercept)
In the hosting view/activity:
override fun dispatchKeyEvent(event: KeyEvent): Boolean { if (event.action == KeyEvent.ACTION_DOWN) { val code = event.keyCode val digit = when (code) { KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_NUMPAD_0 -> '0' KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_NUMPAD_1 -> '1' KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_NUMPAD_2 -> '2' KeyEvent.KEYCODE_3, KeyEvent.KEYCODE_NUMPAD_3 -> '3' KeyEvent.KEYCODE_4, KeyEvent.KEYCODE_NUMPAD_4 -> '4' KeyEvent.KEYCODE_5, KeyEvent.KEYCODE_NUMPAD_5 -> '5' KeyEvent.KEYCODE_6, KeyEvent.KEYCODE_NUMPAD_6 -> '6' KeyEvent.KEYCODE_7, KeyEvent.KEYCODE_NUMPAD_7 -> '7' KeyEvent.KEYCODE_8, KeyEvent.KEYCODE_NUMPAD_8 -> '8' KeyEvent.KEYCODE_9, KeyEvent.KEYCODE_NUMPAD_9 -> '9' KeyEvent.KEYCODE_NUMPAD_DOT -> '.' KeyEvent.KEYCODE_NUMPAD_ADD -> '+' KeyEvent.KEYCODE_NUMPAD_SUBTRACT -> '-' else -> null } if (digit != null) { val edit = numberInput.text val start = numberInput.selectionStart.coerceAtLeast(0) val end = numberInput.selectionEnd.coerceAtLeast(0) edit?.replace(start.coerceAtMost(end), end.coerceAtLeast(start), digit.toString()) return true // consumed } } return super.dispatchKeyEvent(event) }
Option C — Generic commit for hardware keys
If you intercept keys, prefer event.unicodeChar:
if (event.action == KeyEvent.ACTION_DOWN) { val ch = event.unicodeChar if (ch != 0 && ch.toChar().isDigit() || ch.toChar() in charArrayOf('.', '+', '-')) { numberInput.text?.insert(numberInput.selectionStart, ch.toChar().toString()) return true } }
How maintainers can verify
- Connect device and run:
adb logcat | grep -i KeyEvent
Press numpad 0–9 on the Clicks case. You should see KEYCODE_NUMPAD_* events reaching the activity.
-
After applying Option A/B/C, repeat: digits should now insert.
-
Sanity-check with top number row and on-screen keyboard.
Workarounds for users (until fixed)
Use the top number row instead of the numpad on the Clicks keyboard.
Toggle “Show on-screen keyboard while physical keyboard is active” (Settings → System → Languages & input → Physical keyboard) and use the soft keypad for digits.
If you want, I can also provide a tiny PR that:
Removes the custom key listener (if present), or
Adds the KEYCODE_NUMPAD_* handling shown above, and