Skip to content

@jsvision/datagrid / resolveGridAction

Function: resolveGridAction()

resolveGridAction(ev, keymap): GridAction | undefined

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

Resolve one key event to a GridAction against a merged keymap, or undefined when the chord is unmapped (the body dispatch then applies its printable/base fallbacks). Never throws.

Pass a keymap produced by mergeKeymap (or DEFAULT_KEYMAP directly) — a map whose chords are all valid. The merged table is compiled once and reused, so this is cheap per keystroke.

Parameters

ev

KeymapKeyEvent

The key event (a structural subset of the core KeyEvent).

keymap

GridKeymap

A merged chord→action map (from mergeKeymap or DEFAULT_KEYMAP).

Returns

GridAction | undefined

The bound GridAction, or undefined when the chord is unmapped.

Example

ts
import { DEFAULT_KEYMAP, resolveGridAction } from '@jsvision/datagrid';
resolveGridAction({ key: 'f2', ctrl: false, alt: false, shift: false }, DEFAULT_KEYMAP); // 'beginEdit'
resolveGridAction({ key: 'j', ctrl: true, alt: false, shift: false }, DEFAULT_KEYMAP); // undefined