MiMo-Code icon indicating copy to clipboard operation
MiMo-Code copied to clipboard

Numpad Keys Not Working in Prompt Input Field

Open caiyilian opened this issue 5 months ago • 1 comments

Description

The numeric keypad (numpad) keys do not work when typing in the prompt input field in MiMo Code. Pressing any key on the numpad (digits 0-9, decimal point, or arithmetic operators like +, -, *, /) produces no input in the text field.

Expected Behavior

Numpad keys should function identically to the main keyboard number keys, inserting the corresponding digits and symbols into the prompt input field.

Actual Behavior

No characters are inserted when pressing numpad keys. The input field remains unchanged.

Reference: Other Applications Work Correctly

This issue appears to be specific to MiMo Code's input handling. The numpad works correctly in:

  • OpenCode (the predecessor/fork base of MiMo Code) - numpad inputs work normally
  • VS Code terminal and editor
  • Windows Notepad, Word, and other native applications
  • Web browsers (Chrome, Edge) in text input fields
  • Claude Code and other CLI-based coding assistants

This suggests the issue lies in how MiMo Code's input field captures or processes keyboard events, specifically for numpad key codes.

Steps to Reproduce

  1. Open MiMo Code (Web UI or Desktop app)
  2. Click on the prompt input field at the bottom
  3. Ensure NumLock is enabled (numpad should be in number input mode)
  4. Press any digit key on the numpad (0-9)
  5. Observe: No digit appears in the input field
  6. Try the main keyboard number row (above QWERTY)
  7. Observe: These work correctly and digits appear

Environment

  • MiMo Code version: 0.1.0
  • Operating System: Windows 11
  • Installation method: npm install -g @mimo-ai/cli
  • Hardware: Standard keyboard with numeric keypad
  • NumLock state: ON (tried both ON and OFF)

Possible Cause (Brief Analysis)

The issue likely stems from how the prompt input field handles keyboard events:

  1. Key Code Mapping: MiMo Code may be using event.key or event.code for keyboard input handling. Numpad keys produce different values:

    • Main keyboard "1": event.key = "1", event.code = "Digit1"
    • Numpad "1": event.key = "1", event.code = "Numpad1"

    If the code checks for event.code.startsWith("Digit"), it would miss numpad inputs.

  2. ContentEditable Handling: The prompt input appears to use a contentEditable div rather than a native <input> element. contentEditable elements have inconsistent behavior with numpad input across browsers and Electron-based apps, especially when combined with custom keyboard event interception.

  3. IME Composition Handling: The code includes checks for event.isComposing and event.keyCode === 229 (IME composing state). Numpad inputs during or after IME composition may be incorrectly filtered out.

  4. PreventDefault Interference: The input field has extensive handleKeyDown event handling with many event.preventDefault() calls for special keys (Arrow keys, Enter, Escape, etc.). It's possible numpad key events are being inadvertently caught in this net, especially if the numpad Enter key is treated differently than the main Enter key.

The fact that OpenCode (the upstream/base project) does not have this issue suggests this is a regression or a specific change in MiMo Code's input handling implementation.

caiyilian avatar Jun 12 '26 06:06 caiyilian

@nightt5879 I noticed you recently fixed a related issue about prompt history (#392). This numpad input problem also seems to involve keyboard event handling in the prompt input field. Would you mind taking a look? The numpad works fine in OpenCode but not in MiMo Code, suggesting something changed in the input handling implementation.

caiyilian avatar Jun 12 '26 06:06 caiyilian