Change FPS Counter toggling method
This commit is contained in:
parent
58f92db8a0
commit
6bc0789c9b
2 changed files with 2 additions and 26 deletions
|
@ -6,23 +6,11 @@ function create_fps_button() {
|
|||
FPSBtn.id = "buttonF2";
|
||||
document.body.appendChild(FPSBtn);
|
||||
|
||||
console.log(`Setting up the FPS key...`);
|
||||
|
||||
FPSBtn.addEventListener("pointerdown", (event) => {
|
||||
console.log(`Pointer down for F2`);
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
sendEvent(false, 113);
|
||||
Graphics._switchFPSMeter();
|
||||
});
|
||||
|
||||
FPSBtn.addEventListener("pointerup", () => {
|
||||
sendEvent(true, 113);
|
||||
});
|
||||
}
|
||||
|
||||
function sendEvent(isUp, keycode) {
|
||||
document.getElementById("GameCanvas").focus();
|
||||
document.dispatchEvent(new KeyboardEvent(isUp ? 'keyup' : 'keydown', { 'key': '', keyCode: keycode }))
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue