https://github.com/ericoporto/kejo
kejo.js 🧀 is keyboard and joystick unified library for games html5 games that already have touch/mouse handled.
https://github.com/ericoporto/kejo
es6 es6-modules event gamedev gamepad joystick joystick-unified-library js keyboard pooling
Last synced: 10 months ago
JSON representation
kejo.js 🧀 is keyboard and joystick unified library for games html5 games that already have touch/mouse handled.
- Host: GitHub
- URL: https://github.com/ericoporto/kejo
- Owner: ericoporto
- License: mit
- Created: 2018-01-12T00:33:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-07T21:56:58.000Z (about 6 years ago)
- Last Synced: 2025-09-03T00:49:23.585Z (10 months ago)
- Topics: es6, es6-modules, event, gamedev, gamepad, joystick, joystick-unified-library, js, keyboard, pooling
- Language: JavaScript
- Homepage: http://ericoporto.github.io/kejo
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kejo_js
kejo.js is keyboard and joystick unified library for games html5 games that already have touch/mouse handled.
# how to use
You have to import this module and instantiate it first.
import KeJo from './kejo.js'
var kejo = new KeJo
Whenever a key is pressed `kejo_KeyPressed` event is emitted, and when it's released, `kejo_KeyReleased` is emitted. You can use event listeners on the window element.
window.addEventListener('kejo_KeyReleased', writeKeyUp,false);
window.addEventListener('kejo_KeyPressed', writeKeyDown,false);
The key is passed as string under `event.detail` .
Alternatively you can monitor the keys under your gameloop using the method `isPressed`.
if( kejo.isPressed(kejo.key.UP) ) {
...
}
The possible keys by default are:
kejo.key.LEFT
kejo.key.UP
kejo.key.RIGHT
kejo.key.DOWN
kejo.key.BUTTONA
kejo.key.BUTTONB
kejo.key.BUTTONX
kejo.key.BUTTONY
# Author
Made by Érico Vieira Porto.
# License
Distributed under MIT license. See [`LICENSE`](https://github.com/ericoporto/kejo_js/blob/master/LICENSE) for more information.