Skip to main content

Keyboard Navigation

OGrid supports comprehensive keyboard navigation for moving between cells, editing values, selecting ranges, and performing clipboard and undo operations -- all without touching the mouse.

Live Demo​

Click a cell, then use Arrow keys, Tab, Enter, or F2
Live
Try it in your framework

The demo above uses Radix UI for styling. To see this feature with the Fluent UI implementation, click "Open in online demo" below the demo.

Quick Example​

import { OGrid } from '@alaarab/ogrid-react-radix';

function App() {
return (
<OGrid
columns={columns}
data={data}
getRowId={(r) => r.id}
editable
/>
);
}
Switching UI libraries

The OGrid component has the same props across all React UI packages. To switch, just change the import:

  • Radix (lightweight, default): from '@alaarab/ogrid-react-radix'
  • Fluent UI (Microsoft 365 / SPFx): from '@alaarab/ogrid-react-fluent' - wrap in <FluentProvider>

Click any cell, or Tab into the grid, to make it the active cell, then use the keyboard to navigate and edit.

The active cell holds real keyboard focus (a roving tabindex): it is the grid's only tab stop, and focus moves with it as you navigate, so screen readers announce each cell. See Accessibility: focus model.

KeyAction
Arrow Up / Down / Left / RightMove active cell in that direction
Ctrl+ArrowJump to the edge of the current data region (Excel-style)
TabMove to the next cell (left to right, then next row). From the last cell, Tab moves focus out of the grid
Shift+TabMove to the previous cell. From the first cell, Shift+Tab moves focus out of the grid
Shift+EnterMove up one cell (Enter on a single cell starts editing)
HomeMove to the first column in the current row
EndMove to the last column in the current row
Ctrl+HomeMove to the first cell in the grid (top-left)
Ctrl+EndMove to the last cell in the grid (bottom-right)
Page DownMove down by one page of rows
Page UpMove up by one page of rows

Cell Selection​

KeyAction
ClickSet active cell
Shift+ArrowExtend selection range from the active cell (the active cell stays put as the anchor)
Ctrl+Shift+ArrowExtend selection to the edge of the current data region
Shift+Home / Shift+EndExtend selection from the active cell to the first / last column of the row
Ctrl+Shift+Home / Ctrl+Shift+EndExtend selection from the active cell to the first / last cell of the grid
Shift+ClickSelect range from active cell to clicked cell
Ctrl+SpaceSelect the whole column(s) the selection covers
Shift+SpaceWithout row selection: select the whole row(s) the selection covers. With rowSelection: toggle the active cell's row (unchanged)
Ctrl+Shift+SpaceSelect all cells
Click a column letter / row numberSelect the whole column / row (with cellReferences); Shift+click or drag across headers extends
← from the first columnMove to the row's checkbox cell (rowSelection="multiple")
Space on the checkbox cellToggle that row
Shift+Space on the checkbox cellSelect the rows from the last toggled row to this one
Space on an editable boolean cellToggle the checkbox
Ctrl+ASelect all cells in the grid (for copy/paste/fill operations, not row selection)

The selection range is highlighted with a green border. The active cell remains visually distinct within the range.

Whole-row and whole-column selections are ordinary cell ranges: copy, Delete, fill (Ctrl+D / Ctrl+R) and the status bar aggregates all work on them. When the selection touches a merged cell it grows to include the whole merge, and the active cell always sits on a merge's top-left (anchor) cell.

Moving inside a selection​

With more than one cell selected, Enter and Tab move the active cell through the selection instead of collapsing it, like Excel. Enter goes down a column and on to the top of the next one; Tab goes across a row and on to the start of the next one. Both wrap from the last cell back to the first, Shift reverses them, and cells covered by a merge are skipped. This also applies when you commit an edit with Enter or Tab, so you can select a block and type values into it one after another.

Cell Selection vs Row Selection

Ctrl+A selects all cells in the grid for spreadsheet operations (copy/paste/fill). This is different from row selection, where the header checkbox selects all rows for bulk operations. See Row Selection and Spreadsheet Selection for details.

Ctrl+Arrow (Data Region Jump)​

Ctrl+Arrow navigates the same way Excel does:

  • Non-empty cell to non-empty neighbor: Jumps to the last non-empty cell before a gap (empty cell) or the grid edge.
  • Non-empty cell to empty neighbor: Skips over the empty cells and lands on the next non-empty cell, or the grid edge if all remaining cells are empty.
  • Empty cell: Jumps to the next non-empty cell in that direction, or the grid edge.

Combine with Shift to extend the selection range to the same target.

Editing​

KeyAction
EnterStart editing the active cell; press again to commit and move down
F2Start editing the active cell (cursor at end of text)
EscapeCancel editing and revert to the original value
Delete / BackspaceClear the contents of selected cells
Any printable characterStart editing and replace cell content with the typed character
Ctrl+DFill down: copy the top row of the selection into the rows below
Ctrl+RFill right: copy the left column of the selection into the columns to its right
Ctrl+;Enter today's date into the active cell
Ctrl+Shift+;Enter the current time (HH:mm, 24-hour) into the active cell

When a cell is in edit mode:

  • Enter commits the value and moves the active cell down; Shift+Enter commits and moves up.
  • Tab commits the value and moves the active cell right.
  • F4 in a formula (text starting with =) cycles the reference at or just before the caret: A1 → $A$1 → A$1 → $A1 → A1. Both ends of a range (A1:B2) change together. F4 works the same way in the formula bar.
  • Formula autocomplete (with formulas on): while the function list is open, Up/Down move, Tab or Enter inserts the function, and Escape closes the list. With the list closed, Enter, Tab and Escape behave as usual. See Formulas.
  • Escape discards the edit and returns to navigation mode.
  • Arrow keys move the cursor within the editor (they do not navigate between cells while editing).

Typing over a cell​

Typing a character on a selected cell opens its editor with that character in place of the old value, as in Excel. It works for text, number and date cells, and through the column's valueParser on commit. Keys held with Ctrl, Cmd or Alt are shortcuts and never start an edit (AltGr characters still type). Space keeps its own bindings (toggling a boolean cell or the row selection), and Enter/F2 open the editor with the existing value.

Cell editorTyping a character
Text, date (and untyped columns)Opens with the character replacing the value
richSelectOpens with the character as the search text
selectOpens the dropdown
checkbox / type: 'boolean'Nothing (Space toggles it)
Custom popover editor (cellEditor component)Opens with the current value (the editor's value type may not be text)

With an input method editor (IME) active, the first keystroke opens an empty editor and composition continues in it.

Dates and times​

Ctrl+; writes today's date (from the local clock) into the active cell without opening the editor. Date columns (type: 'date' or the date editor) get YYYY-MM-DD, which is what the date editor stores; other columns get the date in the column's dateFormat (YYYY-MM-DD by default). Ctrl+Shift+; writes the time as HH:mm. The value goes through the column's valueParser, so a column that rejects it (a number column, for example) is left unchanged. Each is one undo step.

Clipboard​

KeyAction
Ctrl+CCopy selected cells to clipboard (tab-separated)
Ctrl+XCut selected cells (copy + clear originals)
Ctrl+VPaste clipboard contents starting at the active cell (repeated over a larger selection that is an exact multiple of it)
Ctrl+Shift+VPaste values only: computed values, never formulas

Copied data uses tab-separated format compatible with Excel and Google Sheets. Multi-cell selections copy the entire rectangular range.

Undo / Redo​

KeyAction
Ctrl+ZUndo the last cell edit
Ctrl+YRedo the last undone edit

Undo/redo requires the onUndo, onRedo, canUndo, and canRedo props to be wired up (typically via the useUndoRedo hook).

Keyboard Resizing​

Each column's resize handle is a focusable role="separator" (Tab to it from the header). While it has focus:

KeyAction
Arrow Right / Arrow LeftWiden / narrow the column by 10px
Shift+Arrow Right / Shift+Arrow LeftWiden / narrow the column by 1px
HomeShrink the column to its minimum width
EnterKeep the new width and return focus to the grid
EscapeRestore the width the column had when the handle received focus

Keyboard resizing uses the same state path as dragging: onColumnResized fires on every step, the width shows up in getColumnState(), and controlled column state and persistence see it. The column's minWidth is respected.

How It Works​

Keyboard navigation is handled by the useKeyboardNavigation hook in core, which is automatically wired into the grid when cellSelection is enabled (the default). The hook listens for keydown events on the grid wrapper element and translates them into active cell movements, selection range changes, or editing actions.

Disabling Cell Selection​

Set cellSelection={false} to disable keyboard-driven cell navigation, selection, clipboard, and context menu. The grid becomes a read-only display table.

<OGrid
columns={columns}
data={data}
getRowId={(r) => r.id}
cellSelection={false}
/>

macOS​

On macOS, Ctrl is replaced by the Command key for all shortcuts (Cmd+C, Cmd+V, Cmd+Z, etc.). The grid detects the platform automatically.

Props Reference​

TypeFieldDescription
IOGridProps<T>cellSelectionboolean -- enable/disable keyboard navigation and selection (default true)
IOGridProps<T>editableboolean -- enable cell editing via keyboard
IOGridProps<T>onUndoCallback for Ctrl+Z
IOGridProps<T>onRedoCallback for Ctrl+Y
IOGridProps<T>canUndoboolean -- whether undo is available
IOGridProps<T>canRedoboolean -- whether redo is available
  • Context Menu -- right-click menu mirrors keyboard shortcuts
  • Status Bar -- shows aggregations for keyboard-selected ranges
  • Column Pinning -- navigation works seamlessly across pinned and scrollable columns
  • useGridFocus -- headless Arrow / Tab / Enter / Home / End / PageUp / PageDown navigation for your own table