Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions js/rpg_core/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Input.clear = function() {
this._dir8 = 0;
this._preferredAxis = '';
this._date = 0;
this._isReleased = {};
};

/**
Expand All @@ -128,12 +129,32 @@ Input.update = function() {
this._latestButton = name;
this._pressedTime = 0;
this._date = Date.now();
} else if (this._previousState[name] && !this._currentState[name]) {
this._isReleased[name] = true;
} else {
this._isReleased[name] = false;
}
this._previousState[name] = this._currentState[name];
}
this._updateDirection();
};

/**
* Checks whether a key is just released.
*
* @static
* @method isTriggered
* @param {String} keyName The mapped name of the key
* @return {Boolean} True if the key is released
*/
Input.isReleased = function(keyName) {
if (this._isEscapeCompatible(keyName) && this.isTriggered('escape')) {
return true;
} else {
return !!this._isReleased[keyName];
}
};

/**
* Checks whether a key is currently pressed down.
*
Expand Down