<commit_before># kl

Simple keylogger for Linux + X11.

## Requirements

- python 2 or 3
- xlib

## Installation

    pip install kl

## Usage

Using default parameters, the loop sleep 2 centiseconds between iterations, not
transforms keys structure, and outputs to STDOUT.

```python
import kl

kl.run()
```

Changing loop sleep time to 1 centisecond, adding a callback to add a timestamp
to the structure, and writing it to disk.

```python
import json
import kl
import time


def add_time(keys):
    keys['timestamp'] = time.time()
    return keys


def log(keys):
    with open('/tmp/kl.log', 'a') as f:
        f.write(json.dumps(keys) + '\n')


kl.run(sleep_time=.01, transform=add_time, output=log)
```

## Transformers

`kl` comes with functions that apply certain language layouts to pressed keys.

```python
import kl
from kl.transformers import spanish

kl.run(transform=spanish)
```

Actually the language layouts implemented are:

- English (USA) (`english_usa`) (in progress)
- Spanish (`spanish`)<commit_msg>Updated README.<commit_after># kl

Simple keylogger for Linux + X11.

## Requirements

- python 2 or 3
- xlib

## Installation

    pip install kl

## Usage

Using default parameters, the main loop sleep 2 centiseconds between
iterations, not transforms keys structure, and outputs to STDOUT.

```python
import kl

kl.run()
```

Changing the main loop sleep time to 1 centisecond, adding a callback to add a
timestamp to the structure, and writing it to disk.

```python
import json
import kl
import time


def add_time(keys):
    keys['timestamp'] = time.time()
    return keys


def log(keys):
    with open('/tmp/kl.log', 'a') as f:
        f.write(json.dumps(keys) + '\n')


kl.run(sleep_time=.01, transform=add_time, output=log)
```

## Transformers

`kl` comes with functions that apply a certain language layout to pressed
keys.

For example:

```python
import kl
from kl.transformers import spanish

kl.run(transform=spanish)
```

Actually the language layouts implemented are:

- `english_usa` (in progress)
- `spanish`
{'fraction_non_alphanumeric': 0.10628961482203803, 'fraction_numerical': 0.0078010726474890294, 'mean_word_length': 4.017114914425428, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1708041', 'n_tokens_mistral': 679, 'n_tokens_neox': 633, 'n_words': 245}