Skip to content

@jsvision/datagrid / mergeKeymap

Function: mergeKeymap()

mergeKeymap(user?): GridKeymap

Defined in: datagrid/src/keymap.ts:223

Merge a caller's keymap over DEFAULT_KEYMAP (the caller wins per-chord) and return a fresh, frozen table safe to compile and share.

Each caller entry is validated on both axes and dropped — warned via the dev sink, never thrown — on either failure: an unknown GridAction value, or a chord that is malformed under the core grammar (an unknown modifier or key, which createKeymap would otherwise throw on). A valid but unbound chord is simply absent from the map and resolves to undefined at runtime. So one typo can never break grid construction, and every surviving chord parses cleanly.

Parameters

user?

GridKeymap

The caller's chord→action overrides (optional).

Returns

GridKeymap

A fresh frozen map: the default table with the caller's valid overrides applied.

Example

ts
import { mergeKeymap, resolveGridAction } from '@jsvision/datagrid';
const km = mergeKeymap({ 'ctrl+e': 'beginEdit' });   // Ctrl+E now edits; F2 still does
resolveGridAction({ key: 'e', ctrl: true, alt: false, shift: false }, km); // 'beginEdit'