Hi all,
im trying to figure out how to add a new Event Listener for the Right Key on the keyboard.
Like the ones for "keyup" and "keydown".
It doesnt work however. Since the cursor is in the Window_SkillList my goal is that the user can press to right arrow key to change to another window.
im trying to figure out how to add a new Event Listener for the Right Key on the keyboard.
Like the ones for "keyup" and "keydown".
Code:
Input._setupEventHandlers = function() {
document.addEventListener('keydown', this._onKeyDown.bind(this));
document.addEventListener('keyup', this._onKeyUp.bind(this));
window.addEventListener('blur', this._onLostFocus.bind(this));
document.addEventListener('keyright', this._onKeyRight.bind(this));
};
Input._onKeyRight = function(event) {
if (this._shouldPreventDefault(event.keyCode)) {
event.preventDefault();
}
if (event.keyCode === 39) { // Numlock
this.clear();
}
var buttonName = this.keyMapper[event.keyCode];
if (ResourceHandler.exists() && buttonName === 'keyright') {
ResourceHandler.retry();
} else if (buttonName) {
this._currentState[buttonName] = true;
}
};
//---
Scene_BattleFront.prototype.createSkillWindow = function() {
this._skillWindow = new Window_SkillList(350, 350, 500, 500);
this._skillWindow.setHelpWindow(this._helpWindow);
this._skillWindow.setHandler('ok', this.onSkillOk.bind(this));
this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this));
this._skillWindow.setHandler('keyright', this.onKeyRightt.bind(this));
this._skillTypeWindow.setSkillWindow(this._skillWindow);
this.addWindow(this._skillWindow);
};
Scene_BattleFront.prototype.onKeyRightt = function() {
console.log("got it")
};
It doesnt work however. Since the cursor is in the Window_SkillList my goal is that the user can press to right arrow key to change to another window.