# List keyboard shortcuts

> Handle Backspace, Delete, and Tab at list boundaries.

`list_keymap()` handles list-specific key presses around bullet, ordered, and task items. At the start of the first item, Backspace can lift it out of the list.

## Try it

[Try the list-keymap editor example](https://gpdoc.dev/docs/plugins/structure/list-keymap/#list-keymap-example)

## Install

```sh
cargo add gpdoc-plugin-list-keymap
```

## Example

Add `gpdoc-plugin-list-item` and `gpdoc-plugin-bullet-list` to the [Quickstart app](/docs/quickstart/#configure-the-editor) to use the list shortcuts with bullet items.

```rust
use gpdoc::EditorConfig;
use gpdoc_plugin_paragraph::paragraph;
use gpdoc_plugin_list_item::list_item;
use gpdoc_plugin_bullet_list::bullet_list;
use gpdoc_plugin_list_keymap::list_keymap;


let config = EditorConfig::builder()
    .plugin(paragraph())
    .plugin(list_item())
    .plugin(bullet_list())
    .plugin(list_keymap())
    .build()
    .expect("configure editor");
```

Create a bullet list, place the caret at the beginning of its first item, and press **Backspace**. The editor lifts the item into a paragraph.

## Lift the first item with Backspace

```rust
use gpdoc::{DocPos, Editor, Node, Selection};


let mut editor = Editor::from_document(&config, vec![Node::textblock("paragraph", "First item")])?;
editor.run(gpdoc_plugin_bullet_list::Toggle)?;
editor.select(Selection::caret(DocPos(3)))?;
editor.run(gpdoc_plugin_list_keymap::Backspace)?;


assert_eq!(editor.document().blocks()[0].kind, "paragraph");
```

## Settings

`gpdoc_plugin_list_keymap::list_keymap()` takes no options. Register it alongside the list types you use. See [Combine list plugins](/docs/lists/) for an example with bullet, ordered, and task lists.

## Commands

Each command requires a collapsed text selection.

### `listBackspace`

At the beginning of the first item, lift the item one level. At the beginning of a later item, join its first paragraph to the preceding item’s final paragraph.

```rust
editor.run(gpdoc_plugin_list_keymap::Backspace)?;
```

### `listDelete`

At the end of an item, join its final paragraph to the following item’s first paragraph. Both sides of the boundary must be paragraphs.

```rust
editor.run(gpdoc_plugin_list_keymap::Delete)?;
```

### `listTab`

At the start of a text block immediately after a list, move that block into the last list item if the schema accepts it.

```rust
editor.run(gpdoc_plugin_list_keymap::Tab)?;
```

## Keyboard shortcuts

| Shortcut                             | Command         |
| ------------------------------------ | --------------- |
| **Backspace** or **Mod + Backspace** | `listBackspace` |
| **Delete** or **Mod + Delete**       | `listDelete`    |
| **Tab**                              | `listTab`       |

## Source code

[list-keymap/src/lib.rs](/source/plugins/list-keymap/src/lib.rs.txt)