Files
ghostty/example/wasm-key-encode/README.md
Mitchell Hashimoto 3fc04fd4ae build: replace lib-vt step with -Demit-lib-vt option
Remove the dedicated `zig build lib-vt` step and replace it with a
`-Demit-lib-vt` build option. This fixes two problems:

1. We can default XCFramework, app, etc. steps to false if emit-lib-vt
   is true, so that the lib-vt build doesn't pull in unrelated
   artifacts. **Most importantly, lib-vt alone can be build without
   full Xcode installations.**

2. We can build lib-vt as part of a bundle with other artifacts if we
   really want.
2026-03-21 07:03:06 -07:00

41 lines
887 B
Markdown

# WebAssembly Key Encoder Example
This example demonstrates how to use the Ghostty VT library from WebAssembly
to encode key events into terminal escape sequences.
## Building
First, build the WebAssembly module:
```bash
zig build -Demit-lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall
```
This will create `zig-out/bin/ghostty-vt.wasm`.
## Running
**Important:** You must serve this via HTTP, not open it as a file directly.
Browsers block loading WASM files from `file://` URLs.
From the **root of the ghostty repository**, serve with a local HTTP server:
```bash
# Using Python (recommended)
python3 -m http.server 8000
# Or using Node.js
npx serve .
# Or using PHP
php -S localhost:8000
```
Then open your browser to:
```
http://localhost:8000/example/wasm-key-encode/
```
Focus the text input field and press any key combination to see the encoded output.