Keyboard & Mouse – Computer Fundamentals & Hardware
Computer Fundamentals & Hardware – Advanced University Notes (MIT‑style)
1. Introduction
| Device | Purpose | Key Characteristics |
|---|---|---|
| Keyboard | Text / command input | 101‑key or 104‑key layout, QWERTY, mechanical vs membrane, key‑switch type |
| Mouse | Pointing/selection | Optical/laser sensor, DPI/ppi, scroll wheel, buttons, joystick mode |
These peripherals provide the Human‑Computer Interface (HCI) that translates user intent into machine‑processable signals. Understanding their electrical, mechanical, and protocol aspects is essential for system design, troubleshooting, and optimizing latency.
2. Keyboard – From Mechanical Switch to USB HID
2.1 Mechanical Foundations
-
Key Switch
- Membrane: layers of conductive traces; pressure closes circuit.
- Mechanical: physical spring + metal contact.
- Key‑press: contact closure → current flow.
-
Matrix Scanning
- Keys arranged in an (R \times C) matrix.
- Row drivers: supply voltage to rows.
- Column sense: detect voltage on columns.
- Debounce: mechanical bounce (~10–20 ms); software/firmware filtering.
-
Electrical Parameters
- Current: < 5 mA per key.
- Voltage: 5 V logic (or 3.3 V in modern keyboards).
- Power consumption: < 100 mW idle.
2.2 Firmware & Protocol
| Layer | Function |
|---|---|
| Microcontroller | Processes matrix, debounces, buffers key codes |
| Bootloader | Allows firmware updates via USB |
| HID Class | Human Interface Device; reports keycodes (USB HID Usage Tables) |
- Report Descriptor: defines layout, modifiers, LED status.
- Polling Rate: typical 125 Hz (8 ms).
- Latency: ~4–6 ms from key press to OS event.
2.3 Edge Cases & Failure Modes
| Issue | Likely Cause | Mitigation |
|---|---|---|
| Ghosting / Key Rollover | Limited matrix design (2‑K or 6‑K) | Full‑row/col matrix, diodes per key |
| Sticky Keys | Dirt / debris | Regular cleaning, high‑quality switches |
| Out‑of‑Order Registering | Firmware bug, insufficient debounce | Increase debounce time, use hardware debounce |
| Power Loss During Update | Battery‑powered keyboards | Safe‑bootloader with checksum verification |
2.4 Advanced Topics
- Mechanical Switch Variants: Cherry MX, Kailh, Topre, etc.
- Switch Tactile / Clicky / Linear – mechanical feedback.
- Force‑feedback & Haptic Actuators – vibration motors.
- Programmable Keymaps – firmware like QMK or VIA.
- Low‑Power Modes – USB suspend, power‑down states.
3. Mouse – From Optical Sensor to Human‑Computer Interaction
3.1 Sensor Mechanics
| Sensor | Principle | Key Specs |
|---|---|---|
| Optical | Light source + photodiode; detects changes in reflected light | 400–16,000 DPI, 60–120 Hz |
| Laser | Infrared laser; higher resolution, works on almost any surface | 1,000–120,000 DPI, 400 Hz |
- Image Capture: 8‑bit grayscale sensor, >2000 px resolution.
- Image Processing: Cross‑correlation, optical flow, phase detection.
- Update Rate: Sensor reports delta movement every frame.
3.2 Mouse Buttons & Wheel
- Buttons: Mechanical switches, usually 2–5.
- Scroll Wheel: Rotary encoder or optical sensor; generates incremental events.
- Joystick Mode: 2‑axis continuous input, used in gaming.
3.3 Protocols
| Transport | Typical Speed | Latency | Notes |
|---|---|---|---|
| USB 2.0 | 480 Mbps | ~1 ms | HID class, low latency |
| Bluetooth LE | 1 Mbps | ~2–3 ms | Power‑efficient, increased jitter |
| Wireless RF (2.4 GHz) | 2–3 Mbps | < 1 ms | Proprietary protocols (Logitech, Razer) |
3.4 Edge Cases & Failure Modes
| Issue | Likely Cause | Mitigation |
|---|---|---|
| Surface‑dependent accuracy | Low‑contrast surfaces | Use laser sensor, add surface mat |
| Wheel drift | Mechanical wear, dust | Replace wheel assembly, clean bearings |
| Button chatter | Contact bounce | Firmware debounce, mechanical redesign |
| Signal loss | RF interference | Use adaptive frequency hopping, secure pairing |
3.5 Advanced Topics
- DPI Scaling & Sensitivity Profiles – per‑application precision.
- Gyroscopic Mouse – adds inertial measurement for 6‑DOF control.
- Haptics & Force Feedback – vibration motors for input cues.
- Eye‑Tracking & Touch Input – next‑gen pointing devices.
4. Comparative Analysis: Keyboard vs Mouse
| Feature | Keyboard | Mouse |
|---|---|---|
| Input type | Discrete (keycodes) | Continuous (delta X/Y) |
| Typical latency | 4–6 ms | 1–2 ms |
| Power source | Wired (USB) or battery | Wired or wireless |
| Sensitivity | Fixed (key press) | DPI adjustable |
| Haptic feedback | None (mechanical) | Vibration motors |
| Edge‑case complexity | Matrix ghosting | Surface dependence |
5. Challenging Problem (MIT‑style)
Problem Statement
A compact wireless keyboard (battery‑powered) is used in a noisy industrial environment where electromagnetic interference (EMI) from heavy machinery spikes every 50 ms. The keyboard firmware reports key events at 125 Hz.Tasks
- Model the effect of EMI on the keyboard’s matrix scanning circuit, assuming the EMI induces a transient voltage spike of 0.5 V across the rows.
- Derive the minimum debounce time required to guarantee that no false key press is registered, given that a