# arrow-table

> Navigate HTML tables with arrow keys.

Latest version **1.0.0** (published 2018-08-20) · 0 weekly downloads

## Install

```sh
npm install arrow-table
pnpm add arrow-table
yarn add arrow-table
bun add arrow-table
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-08-20 |
| First published | 2018-08-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 184.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gary Green |
| Maintainers | garygreen |

## Links

- npm: https://www.npmjs.com/package/arrow-table
- npm.io page: https://npm.io/package/arrow-table

## Recent versions

- 1.0.0 (latest) — 2018-08-20

## README

# Arrow Table

Navigate HTML tables with arrow keys.

![demo](resources/demo.gif)

## Usage

```javascript
$('#my-table').arrowTable();
```

## Examples

### Enabling only certain keys
```javascript
$('#my-table').arrowTable({
	enabledKeys: ['up', 'down']
});
```

### Using `beforeMove`

You can use this callback to decide whether to allow the move or not. If you return `false` the plugin will stop the move.

```javascript
$('#my-table').arrowTable({
	focusTarget: 'input, textarea',
	beforeMove: function(input, targetFinder, direction) {
		// Determine the target
		var target = targetFinder();
		if (direction === 'up' && $(target).is('textarea'))
		{
			// Don't allow move
			return false;
		}

		// Return nothing to allow the move
	}
});
```

It's even possible to modify the table in the `beforeMove` callback adding a row and the plugin will find the newly added row.

```javascript
$('#my-table').arrowTable({
	beforeMove: function(input, targetFinder, direction) {
		if (direction === 'down')
		{
			$(input).closest('table').find('tbody').append('<tr><td><input type="text"/></td></tr>');
		}
	}
});
```

See all possible options below.

## Options

Option          | Default                           | Description
----------------|-----------------------------------|--------------
enabledKeys     | `['left', 'right', 'up', 'down']` | Enabled keys
listenTarget    | `'input'`                         | Target to listen for key move events
focusTarget     | `'input'`                         | Target to focus after move
continuousDelay | `50`                              | Delay in ms before moving onto next cell when holding arrow keys down
beforeMove      | `$.noop`                          | Before moving callback. Return `false` to stop move
afterMove       | `$.noop`                          | After moving complete callback.

## API

### destroy
```javascript
$('#my-table').arrowTable('destroy');
```
Destroy the plugin instance

---
_Source: https://npm.io/package/arrow-table · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
