An open API service indexing awesome lists of open source software.

https://github.com/eu-ge-ne/kitty-keys

Kitty keyboard protocol parser library for Node.js, Deno and Bun.
https://github.com/eu-ge-ne/kitty-keys

bun deno javascript kitty-terminal nodejs parser terminal tui typescript

Last synced: 2 months ago
JSON representation

Kitty keyboard protocol parser library for Node.js, Deno and Bun.

Awesome Lists containing this project

README

          

# @eu-ge-ne/kitty-keys

[Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol)
parser library for Node.js, Deno and Bun.

[![JSR](https://jsr.io/badges/@eu-ge-ne/kitty-keys)](https://jsr.io/@eu-ge-ne/kitty-keys)
[![JSR Score](https://jsr.io/badges/@eu-ge-ne/kitty-keys/score)](https://jsr.io/@eu-ge-ne/kitty-keys)
[![codecov](https://codecov.io/gh/eu-ge-ne/kitty-keys/branch/main/graph/badge.svg?token=AH09FY4Y9O)](https://codecov.io/gh/eu-ge-ne/kitty-keys)

- [Installation](#installation)
- [Deno](#deno)
- [Node.js](#nodejs)
- [Bun](#bun)
- [Example](#example)
- [Links](#links)
- [License](#license)

## Installation

### Deno

```bash
deno add jsr:@eu-ge-ne/kitty-keys
```

### Node.js

```bash
# pnpm
pnpm i jsr:@eu-ge-ne/kitty-keys

# yarn
yarn add jsr:@eu-ge-ne/kitty-keys

# npm
npx jsr add @eu-ge-ne/kitty-keys
```

### Bun

```bash
bunx jsr add @eu-ge-ne/kitty-keys
```

## Example

```ts ignore
import { Key, set_flags } from "jsr:@eu-ge-ne/kitty-keys";

Deno.stdin.setRaw(true);

const flags = set_flags({
disambiguate: true,
events: true,
alternates: true,
all_keys: true,
text: true,
});

Deno.stdout.writeSync(flags);

self.onunload = () => {
Deno.stdout.writeSync(set_flags({}));

console.log("Exit");
};

const reader = Deno.stdin.readable.getReader();

while (true) {
const { value } = await reader.read();

const result = Key.parse(value!);
if (!key) {
continue;
}

const [key, bytes_parsed] = result;

console.log(key);

if (key.name === "c" && key.ctrl) {
break;
}
}
```

## Links

-
-

## License

[MIT](https://choosealicense.com/licenses/mit)