-
Notifications
You must be signed in to change notification settings - Fork 4
/
RS_Focus.js
58 lines (54 loc) · 1.72 KB
/
RS_Focus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//================================================================
// RS_Focus.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2020 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @target MZ
* @plugindesc This plugin allows you to maintain the window focus during the game. <RS_Focus>
* @author biud436
* @url https://biud436.tistory.com/
*
* @help
* =======================================================================
* Change Log
* =======================================================================
* 2021.05.08 (v1.0.1) :
* - Removed the strikethrough on the KeyboardEvent.keycode.
* 2021.10.11 (v1.0.2) :
* - Fixed an event listener for the key code of the 'F12' key.
*/
(() => {
"use strict";
const pluginParams = $plugins.filter((i) => {
return i.description.contains("<RS_Focus>");
});
SceneManager.isGameActive = function () {
try {
if (Utils.isNwjs()) return true;
return window.top.document.hasFocus();
} catch (e) {
// SecurityError
return true;
}
};
/**
* @param {KeyboardEvent} event
*/
SceneManager.onKeyDown = function (event) {
const code = event.code || event.key;
if (!event.ctrlKey && !event.altKey) {
switch (code) {
case "F5": // F5
this.reloadGame();
break;
case "F8": // F8
this.showDevTools();
break;
}
}
};
})(RS.Focus);