ghost-keyboard

1.0.6 • Public • Published

Ghost Keyboard

image image image

Simulate any keyboard behavior of any keyboard language. Using Ghost Keyboard you can:

  • Imitates an input typing and get the output value.
  • Convert the typing on a HTMLInputElement to another language even not installed on OS.

No dependency | Browser compatibility: IE10+, Chrome, Safari, Firefox


Check out the DEMO PAGE.

Languages

  • English (en) 🇺🇸
  • Korean (ko) 🇰🇷

Options

  • lang Language abbreviation.
  • value (optional) Initial input value.
  • input(optional) HTMLInputElement that will connect with Ghost Keyboard.
  • pattern (optional) RegExp Allow only values that match the pattern.

Usage

$ npm install ghost-keyboard --save
import GhostKeyboard from 'ghost-keyboard';
 
GhostKeyboard({
    lang: 'en',
    value: '',
    input: document.getElementById('input_id'),
    pattern: /[a-zA-Z0-9.@]/g
});

Or manually download and link ghost-keyboard.min.js in your HTML, It can also be downloaded via UNPKG:

API

Ghost Keyboard also provide an API if you want to use without a real input.

let GhostKeyboard = require('ghost-require');
 
let EnglishKeyboard = GhostKeyboard({lang: 'en'});
keyboard.type('KeyI', {shiftKey: true}); // "I"
keyboard.type('Space'); // "I "
keyboard.type('KeyL'); // "I l"
keyboard.type('KeyU'); // "I lu"
keyboard.type('KeyV'); // "I luv"
keyboard.type('Space'); // "I luv "
keyboard.type('CapsLock'); // "I luv "
keyboard.type('KeyU'); // "I luv U"
 
let KoreanKeyboard = GhostKeyboard({lang: 'ko'});
KoreanKeyboard.type('KeyT'); //
KoreanKeyboard.type('KeyK'); //
KoreanKeyboard.type('KeyF'); //
KoreanKeyboard.type('KeyK'); //사라
KoreanKeyboard.type('KeyD'); //사랑
console.log(KoreanKeyboard.value);
 
KoreanKeyboard.changeLang('en');
console.log('tkfkd');

Development

You will need Node.js installed on your system.

To develop, Install dependencies, Get the code:

$ git clone https://github.com/fill-lima/ghost-keyboard.git
cd ghost-keyboard # Into the directory 
$ npm install       # Install dependencies 

To develop, run the self-reloading:

$ npm start

To develop and check tests at same time.

$ npm run dev

To build, run:

$ npm run build

To contribute, please fork GhostKeyboard, add your patch and tests for it (in the test/ folder) and submit a pull request.

To do

  • Add compatibility to textarea input
  • Add option of keyboard layout
  • Other keyboard languages
  • Convert typed text in other keyboard layout

License

MIT © Felipe Lima

Readme

Keywords

Package Sidebar

Install

npm i ghost-keyboard

Weekly Downloads

3

Version

1.0.6

License

MIT

Unpacked Size

237 kB

Total Files

34

Last publish

Collaborators

  • talktofill