Design a keyboard and mouse input system
Company: Amazon
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Technical Screen
Design an input processing system that captures keyboard and mouse events and reconstructs what the user typed. Requirements: handle keydown/keyup, key repeat, modifier keys, backspace/delete, cursor movement and text selection via mouse, copy/cut/paste, and IME/composition sequences; maintain timestamps and total ordering across devices; expose APIs such as recordEvent(event), getCurrentText(), getSelectionRange(), undo(), and redo(); persist an event log and allow replay to derive final text; handle debouncing and lost/duplicated events; define data models for events and sessions. Describe the high-level components, core data structures, recovery strategy after crashes, testing strategy, and performance considerations (latency, throughput, memory).
Quick Answer: This question evaluates a candidate's competency in designing a cross-platform input processing layer, encompassing event modeling and ordering, IME/composition handling, pointer and selection semantics, deterministic event logging and replay, and resilience to lost or duplicated events.