# Shortcuts

`PlutoGrid` has default shortcut keys set, and users can change or set shortcut keys.

#### Shortcut Range

The scope of the shortcut depends on the focus.
* `PlutoGrid` : In the state that `TextField` is not focused.
   You can set custom shortcut keys.
* `TextField` : In case the cell in edit state or `TextField` of column filtering is focused.
   You cannot set custom shortcut keys.

#### Customizable shortcuts in the `PlutoGrid` range

* ArrowKeys: Moves the focus of the current cell up, down, left and right.
* Shift + ArrowKeys : Moves a cell or row up, down, left and right to select.
* PageUp/Down : Moves the focus of the current cell up and down by page unit.
* Shift + PageUp/Down : Moves cells or rows up and down and selects in units of pages.
* Alt + PageUp/Down : Moves the current page when pagination is enabled.
* Tab or Shift + Tab : Moves the focus of the current cell to the left or right.
  If you hit the left and right ends, set `PlutoGridConfiguration.tabKeyAction` to `moveToNextOnEdge` to continue moving.
* Enter or Shift + Enter : Sets the current cell to edit state or calls the `PlutoGrid.onSelected` callback if `PlutoGird` is in selection mode.
  Additional actions can be set with `PlutoGridConfiguration.enterKeyAction`.
* Escape: When `PlutoGird` is in selection mode, `PlutoGrid.onSelected` is called with `PlutoGridOnSelectedEvent` containing a null value which means cancel the selection.
  In the non-selection mode, the edit state of the cell is canceled.
* Home or End: Moves the focus of the current cell to the left and right ends.
* Control + Home/End : Moves the focus of the current cell up and down.
* Shift + Home/End : Select cells all the way to the left or right.
* Control + Shift + Home/End : Select a cell or row all the way up, down, left, and right.
* F2 : Set the cell to the edit state. In case of date, time, or selection type column, the popup is called.
* F3 : If the current cell is in the focused state, the focus moves to the column filter of the current cell.
  This function is valid only when column filter is enabled with `PlutoGridStateManager.setShowColumnFilter`.
  If the `F3` key is pressed once again while the focus is moved to the column filter, the column filter pop-up is called.
  Also, if you press the `Escape` key in the column filter focus, the focus is moved to the cell before moving.
* F4 : Toggles column sorting. Only valid if `PlutoColumn.enableSorting` is enabled.
* Control + C : Copies the values ​​of the current cell or row or the selected cell or row to the clipboard.
* Control + V : Paste values ​​into the current cell or row or the selected cell or row.
* Control + A : Select all cells or rows.

#### How to set custom shortcut keys

```dart
PlutoGrid(
  configuration: PlutoGridConfiguration(
    shortcut: PlutoGridShortcut(
      actions: {
        // This is a Map with basic shortcut keys and actions set.
        ...PlutoGridShortcut.defaultActions,
        // You can override the enter key behavior as below.
        LogicalKeySet(LogicalKeyboardKey.enter): CustomEnterKeyAction(),
      },
    ),
  ),
);

// Create a new class that inherits from PlutoGridShortcutAction
// If the execute method is implemented, 
// the implemented method is executed when the enter key is pressed.
class CustomEnterKeyAction extends PlutoGridShortcutAction {
  @override
  void execute({
    required PlutoKeyManagerEvent keyEvent,
    required PlutoGridStateManager stateManager,
  }) {
    print('Pressed enter key.');
  }
}
```

> If you have any questions or need to add features, please register on GitHub.
  [PlutoGrid Github](https://github.com/bosskmk/pluto_grid)
