@jsvision/core / redactEvent
Function: redactEvent()
redactEvent(
event):RedactedEvent
Defined in: safety/redact.ts:53
Reduce a decoded input event to a shape that is safe to log — drops any raw content while keeping the structural facts (modifiers, coordinates, lengths) useful for debugging. Log the result of this, never a raw event.
- Printable key (a character was typed): becomes
{type:'key', printable:true, ctrl, alt, shift}— the character itself is dropped. - Named key (e.g. Enter, arrows): keeps its name, e.g.
{type:'key', key:'enter', ctrl, alt, shift}. - Paste: yields only
{type:'paste', length, truncated}— never the text. - Mouse / wheel / focus: carry no secrets, so coordinates, direction, and the focus flag pass through.
Parameters
event
Any decoded input event.
Returns
The redacted, log-safe view. Pure; never mutates event.
Example
ts
import { redactEvent } from '@jsvision/core';
// A typed 'a' — the character is stripped, only the modifiers survive.
redactEvent({ type: 'key', key: 'a', codepoint: 97, ctrl: false, alt: false, shift: false });
// => { type: 'key', printable: true, ctrl: false, alt: false, shift: false }
// Safe to log inside your input handler:
// logger.debug('input', 'event', redactEvent(event));