# caret-xy

> Viewport-based (fixed) caret position for HTML input and textarea elements

Latest version **2.0.3** (published 2019-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install caret-xy
pnpm add caret-xy
yarn add caret-xy
bun add caret-xy
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2019-07-05 |
| First published | 2017-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 48.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Tan Nhu |
| Maintainers | tnhu |

## Links

- npm: https://www.npmjs.com/package/caret-xy
- Repository: https://github.com/tnhu/caret-xy
- Issues: https://github.com/tnhu/caret-xy/issues
- npm.io page: https://npm.io/package/caret-xy

## Recent versions

- 2.0.3 (latest) — 2019-07-05
- 2.0.2 — 2018-03-05
- 2.0.1 — 2018-01-20
- 2.0.0 — 2017-11-23
- 1.1.12 — 2017-11-22
- 1.1.11 — 2017-11-22
- 1.1.10 — 2017-11-22
- 1.1.9 — 2017-11-22
- 1.1.8 — 2017-11-22
- 1.1.7 — 2017-11-22
- 1.1.6 — 2017-11-22
- 1.1.5 — 2017-11-20
- 1.1.4 — 2017-11-20
- 1.1.3 — 2017-11-19
- 1.1.2 — 2017-11-19
- … 7 more at https://npm.io/package/caret-xy/versions

## README

Viewport-based (fixed) caret position for HTML input and textarea elements. This project is based on [textarea-caret-position](https://github.com/component/textarea-caret-position).

```
npm i caret-xy
```

or

```
yarn add caret-xy
```

## API

```javascript
caretXY(element, position)
```

- `element` input or textarea DOM element.
- `position` is an integer indicating the location of the caret (defaults to `element.selectionEnd`).

## Sample

```javascript
import caretXY from 'caret-xy'

const input = document.querySelector('input')
caretXY(input)
```

## Known Issue

- Does not work properly for `<input type="email"/>`, `<input type="password"/>` (`element.selectionEnd` always returns `null`).

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