unityinput
v0.0.30
Published
[](http://badge.fury.io/js/unityinput) [](https://travis-ci.org/digijin/inputjs) [;
let gameloop = () => {
if (input.getButton("fire")) {
console.log("pew pew pew");
}
input.endTick();
};
setInterval(gameloop, 100);
checking if a button is currently down
let input = new Input({
keyboardMapping: {
ctrl: 17
},
buttons: {
fire: {
type: "keyboard",
key: "ctrl"
}
}
});
let gameloop = () => {
if (input.getButton("fire")) {
console.log("pew pew pew");
}
input.endTick();
};
checking if a key is pressed in the last frame
let input = new Input({
keyboardMapping: {
ctrl: 17
}
});
let gameloop = () => {
if (input.getKeyDown("ctrl")) {
console.log("pew pew pew");
}
input.endTick();
};
Notes
getButtonDown is currently not supporting gamepad.
Dev
Test are written in both jest and karma/jasmine/webpack
One-off tests
yarn test
yarn karma
Watchers
yarn test:watch
yarn karma:watch
Webpack dev server
yarn dev
and then hit up http://localhost:8080/demo/
in your browser.
Coverage outputted to console and /coverage/html
Docs
docs can be generated by cloning the repo and running
npm install
npm run docs