writetrack
v0.4.3
Published
Lightweight keystroke telemetry capture for web applications
Maintainers
Readme
WriteTrack
Detect AI-generated and pasted text through keystroke dynamics.
WriteTrack analyzes how text was entered, not what was written. Human typing has natural variation in timing, rhythm, and corrections. Pasted or AI-generated text arrives all at once with no behavioral fingerprint. WriteTrack captures the difference.
- <8KB gzipped
- 0 dependencies
- <1ms per keystroke
- 100% client-side
Installation
npm install writetrackQuick Start
import { WriteTrack } from 'writetrack';
const responseField = document.getElementById('response-field')!;
const tracker = new WriteTrack(responseField);
tracker.start();
// User types...
// Collect captured data
const events = tracker.getRawEvents();
const pastes = tracker.getClipboardEvents();
tracker.stop();Works with any text input, textarea, or contenteditable element. First-party integrations for React, Vue, TipTap, CKEditor 5, ProseMirror, and Quill. Output sinks for webhooks, Datadog, Segment, and OpenTelemetry. TypeScript definitions included.
What it captures
WriteTrack instruments your text inputs and records the behavioral signals behind every keystroke:
- Timing intervals — milliseconds between each keystroke
- Rhythm variance — consistency or erratic cadence
- Correction patterns — backspaces, rewrites, hesitation
- Clipboard events — paste, copy, cut with content and context
- Selection events — text selections via mouse, keyboard, or programmatic
Use cases
Education — Flag essays that were pasted rather than composed. Give instructors behavioral context alongside content.
Research — Distinguish survey respondents who engaged thoughtfully from those who copy-pasted boilerplate.
Compliance — Add a behavioral layer to form submissions. Know when attestations were typed versus pasted.
API
Constructor
new WriteTrack(options: WriteTrackOptions | HTMLElement)Methods
| Method | Returns | Description |
| ---------------------- | ------------------ | ----------------------------- |
| start() | void | Begin capturing events |
| stop() | void | Stop capturing and clean up |
| getRawEvents() | KeystrokeEvent[] | All captured keystroke events |
| getClipboardEvents() | ClipboardEvent[] | Paste/copy/cut events |
| getSelectionEvents() | SelectionEvent[] | Text selection events |
| getUndoRedoEvents() | UndoRedoEvent[] | Undo/redo events |
| getSessionDuration() | number | Session duration in ms |
| getKeystrokeCount() | number | Total keystrokes captured |
| getText() | string | Current text content |
Types
interface WriteTrackOptions {
target: HTMLElement;
license?: string; // Omit for development/demo mode
}Full type definitions for KeystrokeEvent, ClipboardEvent, SelectionEvent, and UndoRedoEvent are included in the package.
Browser Support
| Browser | Version | | ------- | ------- | | Chrome | 62+ | | Firefox | 56+ | | Safari | 14.1+ | | Edge | 79+ |
All features including license verification work at these versions. License validation uses ECDSA P-256 via crypto.subtle, which has been supported since Chrome 37+, Firefox 34+, Safari 11+, and Edge 79+.
Privacy
WriteTrack runs entirely client-side. Keystroke data never leaves the browser. No servers, no tracking, no external requests.
License
See LICENSE for details.
