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

# PS/2 Keyboard Driver: Input Handling in MVH Kernel

> MVH Kernel uses a PS/2 keyboard driver with English US layout, Shift modifier, and Caps Lock. Keyboard input feeds the interactive shell.

The PS/2 keyboard driver (`ps2-keyboard-en-us`) reads scancodes from the PS/2 controller at I/O port `0x60` and translates them into ASCII characters using a built-in English US keymap. It is the sole source of user input in MVH Kernel — every character you type at the `mvh>` shell prompt passes through this driver. The driver handles the Shift modifier and Caps Lock state internally, so the shell receives clean, correctly-cased characters without any additional processing.

## Layout and Modifier Support

<CardGroup cols={2}>
  <Card title="English US Layout" icon="keyboard">
    The keymap is hard-coded to the standard QWERTY English US layout (en-US). All alphabetic, numeric, and symbol keys follow the US keyboard standard.
  </Card>

  <Card title="Shift Modifier" icon="arrow-up">
    Holding Shift while pressing a key produces the shifted character — uppercase letters, `!@#$%^&*()` from number row, and shifted punctuation — exactly as you would expect on a physical US keyboard.
  </Card>

  <Card title="Caps Lock" icon="lock">
    Pressing Caps Lock toggles the internal caps state. When Caps Lock is active, alphabetic keys produce uppercase letters without requiring Shift. Shift still inverts the case when Caps Lock is on.
  </Card>

  <Card title="Shell Integration" icon="terminal">
    `keyboard_read_char()` blocks until a key is pressed and returns the translated ASCII character. The shell reads characters one at a time and echoes them to the VGA display as you type.
  </Card>
</CardGroup>

## Shell Input Flow

When you type at the `mvh>` prompt, the following sequence occurs:

1. The PS/2 controller raises an IRQ 1 interrupt.
2. The keyboard driver reads the scancode from port `0x60`.
3. The scancode is translated using the en-US keymap, applying the current Shift and Caps Lock state.
4. `keyboard_read_char()` returns the ASCII character to the shell's input loop.
5. The shell echoes the character to VGA and appends it to the command buffer.
6. When you press Enter, the shell dispatches the buffered command for execution.

## Language Switching vs. Keyboard Layout

The `language` shell command lets you switch the language used for shell output messages between English (`en`), German (`de`), Spanish (`es`), and French (`fr`). **This does not change the keyboard layout.** The keyboard layout is always English US regardless of the selected output language. The manifest hard-codes `"keyboard_layout": "en-US"`.

```
mvh> language de    # Shell output switches to German
                    # Keyboard remains en-US QWERTY
```

## API Reference

The keyboard driver exposes one function from `include/mvh/keyboard.h`:

```c theme={null}
char keyboard_read_char(void); // Block until a key is pressed; return the ASCII character
```

This function is a blocking read — it does not return until a valid, printable (or control) character is available. The shell calls it in a tight loop to build each command line.

## Driver ID

The device manager registers this driver under the ID `ps2-keyboard-en-us`. Run `devices` in the shell to confirm it is online.
