TouchInput Issue

So I'm making a mini game for MV and I'm running into an issue with my keyListener function, I have it setup so if you hit the escape key it will pause or unpause the game and this works great, the problem is occurring when I attempt to add in TouchInput.isCancelled() as an alternate way to pause and unpause but whenever I use the right mouse key it will pause the game but will not unpause the game and continue to run the first if statement as if it never paused. Using the keyboard escape key works exactly as it should. I'll show you the function so you get a better idea of what I'm trying to do.


Scene_Catch.prototype.keyListener = function() {
if(!$gamePaused && Input.isTriggered('escape') || TouchInput.isCancelled() ){
LevelManager.createText('Paused', 72, 10, Graphics.height/3, Graphics.width, 'center' );
$gamePaused = true;
AudioManager.playSe(this._pauseSe);
console.log('Paused' + $gamePaused);

} else if($gamePaused && Input.isTriggered('escape') || TouchInput.isCancelled() ){
LevelManager.removeTextSprite();
$gamePaused = false;
AudioManager.playSe(this._unPauseSe);
console.log('Paused' + $gamePaused);
}
};


Thanks in advance for any help.
Try this:


Scene_Catch.prototype.keyListener = function() {
if(!$gamePaused && (Input.isTriggered('escape') || TouchInput.isCancelled() )){
LevelManager.createText('Paused', 72, 10, Graphics.height/3, Graphics.width, 'center' );
$gamePaused = true;
AudioManager.playSe(this._pauseSe);
console.log('Paused' + $gamePaused);

} else if($gamePaused && (Input.isTriggered('escape') || TouchInput.isCancelled() )){
LevelManager.removeTextSprite();
$gamePaused = false;
AudioManager.playSe(this._unPauseSe);
console.log('Paused' + $gamePaused);
}
};




The way you wrote it, the game would read it like this:


if (is not paused and the escape key is pressed) or (the right mouse button is clicked)


But what you want is:


if (is not paused) and (the escape key is pressed or the right mouse button is clicked)
Ahhh, thank you, this works great. I completely forgot the fact you need parenthesis to localize the expressions, I understand where I went wrong, sometimes these things are easy to overlook a fresh pair of eyes always does the trick, again thank you for the help, I appreciate it.

Original thread: https://forums.rpgmakerweb.com/threads/touchinput-issue.61735/