Skip to content

A JavaScript library for interacting with KLE JSON and KLE data structures.

License

Notifications You must be signed in to change notification settings

DamSenViet/kle-js

Repository files navigation

kle-js

A JavaScript library for interacting with KLE JSON and KLE data structures.

Originally ported from keyboard-layout-editor with improvements to make the source code increasingly portable across different language platforms.

Table of Contents

Documentation

To view documentation, examples, visit the documentation site.

Installation

To install and use the library, choose an installation method listed below.

  1. NPM
npm install @damsenviet/kle
  1. YARN
yarn add @damsenviet/kle
  1. CDN
<!-- available under the global namespace 'kle' -->
<script src="https://unpkg.com/@damsenviet/kle"></script>

Quick Start

This quick start demo demonstrates parsing a KLE JSON.

const fs = require('fs');
const path = require('path');
const { Keyboard, KeyboardJSON } = require('@damsenviet/kle');

// relative to this file
const jsonRelativePath = './keyboard.json';
const jsonAbsolutePath = path.join(__dirname, jsonRelativePath);

const keyboardJson = JSON.parse(fs.readFileSync(jsonAbsolutePath, 'utf-8')) as KeyboardJSON;
const keyboard = Keyboard.fromJSON(keyboardJson);

for (const key of keyboard.keys) {
  for (const label of key.labels) {
    // pass
  }
}

The schemas for KLE JSON can be found at kle-json.

Contributing

There are many ways to contribute to this project.

For more information please see the contributing guidelines.

About

A JavaScript library for interacting with KLE JSON and KLE data structures.

Resources

License

Stars

Watchers

Forks

Packages

No packages published