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.
- English (en) 🇺🇸
- Korean (ko) 🇰🇷
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.
$ 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:
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');
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.
- Add compatibility to textarea input
- Add option of keyboard layout
- Other keyboard languages
- Convert typed text in other keyboard layout