> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zerokeyusb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Menu System

> Explore the ZeroKeyUSB menu structure, setup wizard, and how to use every feature safely.

## Simple control, powerful features

ZeroKeyUSB has no buttons, no apps, and no hidden menus — only **five golden touch points** that control everything.\
The menu becomes accessible **after entering your Master PIN** by scrolling past the last credential slot.

***

## Menu structure

```mermaid theme={null}
graph TD
    ROOT["Main Menu"]
    ROOT --> BACKUP["Backup"]
    ROOT --> SETTINGS["Settings"]
    ROOT --> DANGER["Danger Zone"]
    ROOT --> INFO["Info"]
    
    BACKUP --> IMP["Import"]
    BACKUP --> EXP["Export"]
    
    SETTINGS --> ROT["Rotate Screen"]
    SETTINGS --> KB["Keyboard: XX-XX"]
    SETTINGS --> ABOUT["About"]
    
    DANGER --> RPIN["Reset PIN"]
    DANGER --> DEL["Delete Credentials"]
    DANGER --> FACTORY["Factory Reset"]
    DANGER --> BOOT["Bootloader Mode"]
    
    INFO --> SW["SW: x.x.x"]
    INFO --> SN["SN: XXXXXXXX"]
    
    style ROOT fill:#dbeafe,stroke:#2563eb,color:#000
    style DANGER fill:#fee2e2,stroke:#dc2626,color:#000
```

***

## Navigating the menu

| Gesture      | Action                                        |
| ------------ | --------------------------------------------- |
| **Up ↑**     | Move selection up (wraps to bottom)           |
| **Down ↓**   | Move selection down (wraps to top)            |
| **Center ●** | Select / Execute the highlighted item         |
| **Left ←**   | Go back to parent menu or exit to credentials |
| **Right →**  | Exit menu, jump to credential slot 0          |

When a menu has more items than fit on the 4-row display, a **scrollbar with thumb** appears on the right edge. The selection stays visible as you scroll.

***

### 🔁 Backup

| Item       | Action                                                                                                     |
| ---------- | ---------------------------------------------------------------------------------------------------------- |
| **Import** | Receives credentials from the host via USB serial (CDC). Device shows "Waiting for data from the web app." |
| **Export** | Sends all 62 credential slots as plaintext CSV over USB serial. Requires long-press Center authorization.  |

The export/import flow shows an authorization prompt before transferring any data:

```mermaid theme={null}
sequenceDiagram
    participant Host
    participant Device

    Host->>Device: "EXPORT" or "IMPORT"
    Device-->>Host: "AWAIT_AUTH EXPORT"
    Device->>Device: Show "Hold center to authorize"
    
    alt User holds Center
        Device->>Host: Stream CSV data (export)<br/>or receive CSV data (import)
        Device-->>Device: "Export/Import complete"
    else User releases
        Device-->>Device: Cancel, return to menu
    end
```

<Warning>
  Export sends **plaintext credentials** over USB serial. Only perform this on a trusted computer.
</Warning>

***

### ⚙️ Settings

| Item                | Action                                                                                                                              |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| **Rotate Screen**   | Flips the display 180° for left/right-handed use. Also inverts touch controls. Saved in EEPROM.                                     |
| **Keyboard: XX-XX** | Cycles through 9 keyboard layouts (EN-US → DA-DK → DE-DE → ES-ES → FR-FR → HU-HU → IT-IT → PT-PT → SV-SE → EN-US). Saved in EEPROM. |
| **About**           | Shows device info: SW version, serial number, and `zerokeyusb.com`.                                                                 |

***

### ⏱️ TOTP

TOTP is accessed from the credential view, not the main menu. When viewing a credential, scroll **Down past Password** to the **2FA** field:

* If no TOTP secret exists for that slot → shows "No TOTP secret" for 2 seconds.
* If time is not synced → shows "Time not set — Request host time" and sends `REQTIME` over serial.
* If ready → displays a **6-digit code** with a 30-second countdown timer. Refreshes automatically each period. Touch any pad to return.

***

### ⚠️ Danger Zone

Every action in this section shows a **confirmation page** that requires pressing Center to proceed or Left to cancel:

| Item                   | Effect                                                                                                                                                       | Reversible?                                      |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ |
| **Reset PIN**          | Enters the PIN change screen (`EDITPIN`). New PIN + re-provisioning.                                                                                         | Partial — old credentials remain if same AES key |
| **Delete Credentials** | Calls `eraseAll()`: 3-second countdown, then writes encrypted blanks to all 62 slots + clears TOTP metadata.                                                 | ❌ No                                             |
| **Factory Reset**      | Resets config flag to `0x00` + erases all credentials. Next boot starts the setup wizard.                                                                    | ❌ No                                             |
| **Bootloader Mode**    | Sets double-reset magic word (`0xF01669EF` at `0x20007FFC`), then issues `NVIC_SystemReset()`. Device reboots into USB DFU bootloader for firmware flashing. | ✅ Yes (reflash)                                  |

***

### ℹ️ Info

Read-only submenu showing:

* **SW: x.x.x** — firmware version from `zerokeyInfo::getSoftwareVersion()`
* **SN: XXXXXXXX** — hardware serial from the SAMD21 unique ID registers

***

## Setup wizard

The setup wizard runs on first boot (or after factory reset). It consists of **10 internal pages** across **9 visible steps**:

```mermaid theme={null}
graph LR
    W1["1. Welcome"] --> W2["2. Navigation"]
    W2 --> W3["3. Rotate Screen"]
    W3 --> W4["4. Keyboard Layout"]
    W4 --> W5["5. Create PIN"]
    W5 --> W6["6. Confirm PIN"]
    W6 --> W7["7. Unlock Info"]
    W7 --> W8["8. Accounts Info"]
    W8 --> W9["9. Generate IV"]
    W9 --> W10["10. Ready!"]
    
    style W5 fill:#fef3c7,stroke:#d97706,color:#000
    style W6 fill:#fef3c7,stroke:#d97706,color:#000
    style W9 fill:#fee2e2,stroke:#dc2626,color:#000
```

Pages with more than 4 lines of text are **vertically scrollable** using Up/Down. A scrollbar with thumb appears on the right edge.

Each wizard page supports:

* **Right** → advance to next page
* **Left** → go back to previous page
* **Center** → action (toggle orientation, change layout, start PIN entry)
* **Up/Down** → scroll content

***

## Design philosophy

The menu system is intentionally minimalist:

* No deep submenus — every option is **two taps away** from the main menu.
* All destructive actions require explicit Center confirmation on a dedicated page.
* Layout and gestures remain consistent across firmware versions.
* Menu items dynamically update their labels (e.g., keyboard layout shows current selection).

<Note>
  ZeroKeyUSB requires no drivers or software installation.\
  It's recognized as a standard USB keyboard on any operating system.
</Note>
