Skip to content

Conversation

@TigWork
Copy link

@TigWork TigWork commented Oct 29, 2025

Summary

This PR adds support for cell renderers to handle keyboard events directly, allowing custom cells to intercept and respond to key presses before default grid behavior.

Motivation

Currently, cell renderers can respond to mouse events (onClick, onSelect) and deletion (onDelete), but have no way to handle keyboard input. This limitation prevents common use cases such as:

  • Custom keyboard shortcuts for specific cell types
  • In-cell interactions without opening the overlay editor
  • Preventing certain keys from triggering default grid navigation

This feature bridges that gap by providing renderers with keyboard event access, similar to existing mouse event handlers.

Implementation Details

  • Added onKeyDown method to cell renderer interface that receives keyboard event details (key, modifiers) along with cell context (data, bounds, location, theme)
  • Integrated keyboard handler into the data editor's event flow, calling the renderer's onKeyDown when a cell has focus and no overlay is open
  • Handler can optionally return a modified cell value to trigger immediate save, or call preventDefault() to block default keybindings
  • Includes proper validation of returned values (checking for read-only status, editable types) and coordinate system transformations

Breaking Changes

None

Fixes: #1157

let prevented = false;
const newVal = renderer.onKeyDown({
...event,
bounds: event.bounds,
Copy link
Author

@TigWork TigWork Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds is manually given because bounds is required prop in onKeyDown and TS doesn't understand that bounds is always defined from ...event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add keyboard event handler support for custom cell renderers

1 participant