Quick Start
Installation
To use Keywrite on web projects you need to install the @keywrite/web package:
yarn add @keywrite/web
or
npm install @keywrite/web
Usage
Once you have installed the @keywrite/web you can import it to your project:
import { KeywriteWeb } from '@keywrite/web';
You also need a Input-method to start using Keywrite. Keyboard Input-methods map keyboard inputs to symbols, this will allow us to define key stroke combinations that produce a certain symbol.
Lets define a simple input-method to get started:
const myInputMethod = {
a: { value: '∀', next: null },
e: {
value: '∈',
next: {
e: {
value: '∉',
next: null,
},
},
},
};
Next, we initialize our KeywriteWeb instance using a reference to either a
textarea or input element and the Input-method.
// add to HTMLInputElement
new KeywriteWeb(document.querySelector('input'), { myInputMethod });
// add to HTMLTextAreaElement
new KeywriteWeb(document.querySelector('textarea'), { myInputMethod });
The complete code is shown below: