Keyboard
Arrow keys, Tab, Home/End and Page keys move the focused cell, Enter edits and Ctrl+Z undoes; keymap remaps or turns off keys.
Live demoKeyboard navigation
Arrow keys, Tab, Home/End and Page keys move the focused cell.
Code for this demo
import { createGrid } from '@freegridjs/core';
import { demoColumns, makeRows } from '../data';
import { text, tr, type DemoContext } from '../ui';
export default function mount(ctx: DemoContext) {
const { lang } = ctx;
const grid = createGrid(ctx.host, { columns: demoColumns(lang, 10), data: makeRows(10_000, 10), rowSelection: 'multiple', locale: lang });
grid.on('focusChange', e => ctx.log(`focusChange → row ${e.rowIndex + 1}, ${e.colId}`));
grid.on('cellDoubleClick', e => ctx.log(`cellDoubleClick → ${e.colId}: ${String(e.value)}`));
text(ctx, tr(lang, {
en: 'Click a cell, then use ← ↑ → ↓, Tab, Home/End, Ctrl+Home/End, PageUp/PageDown and Space.',
ko: '셀을 클릭한 뒤 ← ↑ → ↓, Tab, Home/End, Ctrl+Home/End, PageUp/PageDown, Space를 눌러 보세요.',
}));
return grid;
}Click a cell or tab into the grid, then:
| Key | Action |
|---|---|
← ↑ → ↓ | Move the focused cell. |
Tab / Shift+Tab | Next / previous cell, wrapping rows; leaves the grid at the ends. |
Home / End | First / last column. |
Ctrl+Home / Ctrl+End | First / last cell. |
PageUp / PageDown | One screen up / down. |
Ctrl+C / Ctrl+V | Copy the focused cell / paste one value into it (Excel text works too). |
Enter / F2 / typing | Start editing an editable cell. |
Enter / Tab / Esc (editing) | Save and move down / save and move right / cancel. |
Delete | Clear the focused cell when it is editable. |
Ctrl+Z / Ctrl+Y | Undo / redo. |
Space | Toggle the focused row’s selection. |
Alt+↓ | Open the column menu (sort, pin, filter …) of the focused cell’s column. |
Esc | Close the column menu, chooser or dialog; focus goes back to the grid. |
Change the keys
keymap remaps or turns off the editing keys. Keys are written like 'Enter', 'F2' or 'Ctrl+Shift+Z' (⌘ counts as Ctrl), and each one maps to an action: 'edit', 'clear', 'undo', 'redo', 'copy', 'cut', 'paste', 'selectAll', 'find', 'columnMenu', or false / 'none' to leave the key to the browser. By default Enter and F2 edit, Delete and Backspace clear, Ctrl+Z undoes, Ctrl+Y or Ctrl+Shift+Z redo, and Alt+↓ opens the column menu.
createGrid(el, {
columns,
data,
keymap: {
Enter: false, // Enter no longer starts editing
'Ctrl+E': 'edit', // Ctrl+E does instead
Delete: 'none', // Delete does nothing
},
});
// actions: 'edit' | 'clear' | 'undo' | 'redo' | 'copy' | 'cut' | 'paste' | 'selectAll' | 'find' | 'none'Keys for cell ranges, find and the context menu are on Cell ranges, Find and Context menu.