mirror-ghostty/example/wasm-key-encode
Mitchell Hashimoto 7d7c0bf5cd
lib-vt: Wasm SGR helpers and example (#9362)
This adds some convenience functions for parsing SGR sequences
WebAssembly and adds an example demonstrating SGR parsing in the
browser.
2025-10-26 13:19:55 -07:00
..
README.md examples/wasm-key-encode: update README 2025-10-23 12:49:38 -07:00
index.html lib-vt: Wasm SGR helpers and example (#9362) 2025-10-26 13:19:55 -07:00

README.md

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:

zig build 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:

# 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.