Metadata-Version: 2.5
Name: datasette-keyboard-shortcuts
Version: 0.1.0
Summary: Datasette plugin for configurable keyboard shortcuts
Project-URL: Homepage, https://github.com/theophilec/datasette-keyboard-shortcuts
Project-URL: Issues, https://github.com/theophilec/datasette-keyboard-shortcuts/issues
Project-URL: CI, https://github.com/theophilec/datasette-keyboard-shortcuts/actions
License-Expression: MIT
Classifier: Framework :: Datasette
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Requires-Dist: datasette>=0.55
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-asyncio; extra == 'test'
Description-Content-Type: text/markdown

# datasette-keyboard-shortcuts

Plugin for configuring keyboard shortcuts for Datasette.

## Installation

```bash
uv add datasette-keyboard-shortcuts
```

## Configuration

Shortcuts can be configured in `datasette.yaml` or `metadata.json`:

```yaml
plugins:
  datasette-keyboard-shortcuts:
    shortcuts:
      - id: run-query
        key: Mod+Enter
        action: run-query
```

### Default shortcuts

`Mod+Enter` runs the SQL query on the query page. `Shift+Mod+F` formats the
query using Datasette's built-in Format SQL button. `Mod` means `Command` on
macOS and `Control` on Windows and Linux.

Configured shortcuts with the same `id` replace defaults. Set
`enabled: false` to disable one. The supported actions are `run-query` and
`format-query`; unknown actions are ignored.

## Adding more shortcuts

The browser runtime exposes `window.datasetteKeyboardShortcuts` for other plugins. You can call it like this:

```js
const unregister = window.datasetteKeyboardShortcuts.register({
  id: "focus-search",
  key: "Mod+K",
  handler: () => document.querySelector("input[type=search]")?.focus(),
});
```

## Development

```bash
uv sync --extra test
uv run pytest
```
