mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixes #32
This commit is contained in:
parent
2c5bb1bb39
commit
1e748a93cb
5 changed files with 6 additions and 42 deletions
|
|
@ -18,11 +18,10 @@ function (Key) {
|
|||
window.onkeyup = this._onKeyUp.bind(this);
|
||||
}
|
||||
|
||||
KeyboardInput.prototype.registerKey = function (keyCode, onKeyDown, onKeyUp, onKeyFrame) {
|
||||
KeyboardInput.prototype.registerKey = function (keyCode, onKeyDown, onKeyUp) {
|
||||
var key = new Key();
|
||||
if(onKeyDown) key.setKeyDownFunction(onKeyDown);
|
||||
if(onKeyUp) key.setKeyUpFunction(onKeyUp);
|
||||
if(onKeyFrame) key.setKeyFrameFunction(onKeyFrame);
|
||||
this._registry[keyCode] = key;
|
||||
}
|
||||
|
||||
|
|
@ -49,25 +48,5 @@ function (Key) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If KeyFrameFunction was set, it is executed when key is active
|
||||
*/
|
||||
KeyboardInput.prototype.update = function () {
|
||||
var callback = null;
|
||||
|
||||
for (var keyCode in this._registry) {
|
||||
var key = this._getKeyByKeyCode(keyCode);
|
||||
|
||||
if (key.getActive()) {
|
||||
callback = key.getKeyFrameFunction();
|
||||
if (callback) {
|
||||
this._playerController[callback]();
|
||||
}
|
||||
}
|
||||
|
||||
callback = null;
|
||||
}
|
||||
}
|
||||
|
||||
return KeyboardInput;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue