Change FPS Counter toggling method

This commit is contained in:
OleSTEEP 2024-03-24 11:58:51 +03:00
parent 58f92db8a0
commit 6bc0789c9b
2 changed files with 2 additions and 26 deletions

View file

@ -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', () => {