Design a keyboard and mouse input system

Quick Overview

An Amazon software-engineer system-design screen: design a system that captures keyboard and mouse events and reconstructs exactly what the user typed. It tests low-latency event capture, total ordering across multiple devices, IME/composition and grapheme-safe text reconstruction, mouse selection and clipboard/undo-redo, plus durable persistence with deterministic crash-safe replay.

Design a keyboard and mouse input system

Company: Amazon

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

##### Question Design an input processing system that captures keyboard and mouse events and can reliably reconstruct **what the user typed** (answering "what did the user input?"). The system must support multiple input devices, preserve a total ordering of events across them, persist an event log, and allow replay to derive the final text. Cover the following: 1. **Event capture and modeling** — handle key down/up, key repeat (auto-repeat), modifier keys, backspace/delete, and text composition. Define the data models for low-level events, normalized/canonical events, derived high-level operations, and sessions. 2. **Mouse and selection** — handle mouse clicks, movement, scroll, double-click (and word/line selection), drag-based text selection, and cursor movement. 3. **Clipboard and editing** — support copy, cut, and paste, plus undo and redo with sensible transaction grouping. 4. **Text reconstruction and IME** — reconstruct user-visible text from the text-input pipeline (TextInput / composition commit), correctly handling IME composition sequences (CompositionStart/Update/End), dead keys, and Unicode grapheme clusters (emoji, combining marks). Do **not** infer text from raw key codes. 5. **Ordering, timestamps, and concurrency** — maintain monotonic timestamps and a total order across multiple devices; discuss event queues, buffering/back-pressure, and thread-safety. 6. **Robustness** — handle debouncing (key/button bounce, mouse-move coalescing), double-click detection, and lost or duplicated events. 7. **APIs** — expose an interface such as `recordEvent(event)`, `getCurrentText()`, `getSelectionRange()`, `undo()`, `redo()`, plus session control and replay (`startSession`, `endSession`, `replay`). 8. **Persistence, recovery, and replay** — persist an append-only event log, support deterministic replay to rebuild final text, and recover correctly after a crash (snapshots + write-ahead log). 9. **Quality** — describe the high-level components, latency/throughput/memory targets, a testing strategy, and failure handling.

Quick Answer: An Amazon software-engineer system-design screen: design a system that captures keyboard and mouse events and reconstructs exactly what the user typed. It tests low-latency event capture, total ordering across multiple devices, IME/composition and grapheme-safe text reconstruction, mouse selection and clipboard/undo-redo, plus durable persistence with deterministic crash-safe replay.

|Home/System Design/Amazon
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
hardSoftware EngineerTechnical ScreenSystem Design
8
0
Question

Design an input processing system that captures keyboard and mouse events and can reliably reconstruct what the user typed (answering "what did the user input?"). The system must support multiple input devices, preserve a total ordering of events across them, persist an event log, and allow replay to derive the final text. Cover the following:

  1. Event capture and modeling — handle key down/up, key repeat (auto-repeat), modifier keys, backspace/delete, and text composition. Define the data models for low-level events, normalized/canonical events, derived high-level operations, and sessions.
  2. Mouse and selection — handle mouse clicks, movement, scroll, double-click (and word/line selection), drag-based text selection, and cursor movement.
  3. Clipboard and editing — support copy, cut, and paste, plus undo and redo with sensible transaction grouping.
  4. Text reconstruction and IME — reconstruct user-visible text from the text-input pipeline (TextInput / composition commit), correctly handling IME composition sequences (CompositionStart/Update/End), dead keys, and Unicode grapheme clusters (emoji, combining marks). Do not infer text from raw key codes.
  5. Ordering, timestamps, and concurrency — maintain monotonic timestamps and a total order across multiple devices; discuss event queues, buffering/back-pressure, and thread-safety.
  6. Robustness — handle debouncing (key/button bounce, mouse-move coalescing), double-click detection, and lost or duplicated events.
  7. APIs — expose an interface such as recordEvent(event) , getCurrentText() , getSelectionRange() , undo() , redo() , plus session control and replay ( startSession , endSession , replay ).
  8. Persistence, recovery, and replay — persist an append-only event log, support deterministic replay to rebuild final text, and recover correctly after a crash (snapshots + write-ahead log).
  9. Quality — describe the high-level components, latency/throughput/memory targets, a testing strategy, and failure handling.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...